1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__))); |
---|
5 | include_once(PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/include/install.inc.php'); |
---|
6 | |
---|
7 | function plugin_install() |
---|
8 | { |
---|
9 | batch_download_install(); |
---|
10 | |
---|
11 | define('batch_download_installed', true); |
---|
12 | } |
---|
13 | |
---|
14 | function plugin_activate() |
---|
15 | { |
---|
16 | if (!defined('batch_download_installed')) |
---|
17 | { |
---|
18 | batch_download_install(); |
---|
19 | } |
---|
20 | } |
---|
21 | |
---|
22 | function plugin_uninstall() |
---|
23 | { |
---|
24 | global $prefixeTable, $conf; |
---|
25 | |
---|
26 | pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = "batch_download" LIMIT 1;'); |
---|
27 | pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets`;'); |
---|
28 | pwg_query('DROP TABLE IF EXISTS `' . $prefixeTable . 'download_sets_images`;'); |
---|
29 | |
---|
30 | rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/'); |
---|
31 | } |
---|
32 | |
---|
33 | |
---|
34 | if (!function_exists('rrmdir')) |
---|
35 | { |
---|
36 | function rrmdir($dir) |
---|
37 | { |
---|
38 | if (!is_dir($dir)) |
---|
39 | { |
---|
40 | return false; |
---|
41 | } |
---|
42 | $dir = rtrim($dir, '/'); |
---|
43 | $objects = scandir($dir); |
---|
44 | $return = true; |
---|
45 | |
---|
46 | foreach ($objects as $object) |
---|
47 | { |
---|
48 | if ($object !== '.' && $object !== '..') |
---|
49 | { |
---|
50 | $path = $dir.'/'.$object; |
---|
51 | if (filetype($path) == 'dir') |
---|
52 | { |
---|
53 | $return = $return && rrmdir($path); |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | $return = $return && @unlink($path); |
---|
58 | } |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | return $return && @rmdir($dir); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | ?> |
---|