source: extensions/BatchDownloader/maintain.inc.php @ 20138

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

make sure zip folder is created on the right place

File size: 1.4 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__)));
5include_once(PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/include/install.inc.php');
6
7function plugin_install() 
8{
9  batch_download_install();
10 
11  define('batch_download_installed', true);
12}
13
14function plugin_activate()
15{
16  if (!defined('batch_download_installed'))
17  {
18    batch_download_install();
19  }
20}
21
22function 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
34if (!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?>
Note: See TracBrowser for help on using the repository browser.