[17656] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | function batch_download_install() |
---|
| 5 | { |
---|
| 6 | global $conf, $prefixeTable; |
---|
| 7 | |
---|
| 8 | // configuration |
---|
| 9 | if (empty($conf['batch_download'])) |
---|
| 10 | { |
---|
| 11 | $batch_download_default_config = serialize(array( |
---|
| 12 | 'groups' => array(), |
---|
| 13 | 'level' => 0, |
---|
| 14 | 'photo_size' => 'original', |
---|
| 15 | 'archive_prefix' => 'piwigo', |
---|
| 16 | 'archive_timeout' => 48, /* hours */ |
---|
| 17 | 'max_elements' => 500, |
---|
| 18 | 'max_size' => 100, /* MB */ |
---|
| 19 | 'last_clean' => time(), |
---|
| 20 | )); |
---|
| 21 | |
---|
| 22 | conf_update_param('batch_download', $batch_download_default_config); |
---|
| 23 | conf_update_param('batch_download_comment', null); |
---|
| 24 | |
---|
| 25 | $conf['batch_download'] = $batch_download_default_config; |
---|
| 26 | $conf['batch_download_comment'] = null; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | // archives directory |
---|
[17660] | 30 | if ( file_exists($conf['data_location']) and !file_exists($conf['data_location'] . 'download_archives/') ) |
---|
[17656] | 31 | { |
---|
| 32 | mkdir($conf['data_location'] . 'download_archives/', 0755); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | // create tables |
---|
| 36 | $query = ' |
---|
| 37 | CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets` ( |
---|
| 38 | `id` mediumint(8) NOT NULL AUTO_INCREMENT, |
---|
| 39 | `user_id` smallint(5) NOT NULL, |
---|
| 40 | `date_creation` datetime NOT NULL, |
---|
| 41 | `type` varchar(16) CHARACTER SET utf8 NOT NULL, |
---|
| 42 | `type_id` varchar(64) CHARACTER SET utf8 NOT NULL, |
---|
| 43 | `nb_zip` smallint(3) NOT NULL DEFAULT 0, |
---|
| 44 | `last_zip` smallint(3) NOT NULL DEFAULT 0, |
---|
| 45 | `nb_images` mediumint(8) NOT NULL DEFAULT 0, |
---|
| 46 | `total_size` int(10) NOT NULL DEFAULT 0, |
---|
| 47 | `status` enum("new","download","done") CHARACTER SET utf8 NOT NULL DEFAULT "new", |
---|
| 48 | PRIMARY KEY (`id`) |
---|
| 49 | ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 |
---|
| 50 | ;'; |
---|
| 51 | pwg_query($query); |
---|
| 52 | |
---|
| 53 | $query = ' |
---|
| 54 | CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'download_sets_images` ( |
---|
| 55 | `set_id` mediumint(8) NOT NULL, |
---|
| 56 | `image_id` mediumint(8) NOT NULL, |
---|
| 57 | `zip` smallint(5) NOT NULL DEFAULT 0, |
---|
| 58 | UNIQUE KEY `UNIQUE` (`set_id`,`image_id`) |
---|
| 59 | ) DEFAULT CHARSET=utf8 |
---|
| 60 | ;'; |
---|
| 61 | pwg_query($query); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | ?> |
---|