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

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

make sure zip folder is created on the right place

File size: 1.4 KB
RevLine 
[16379]1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
[18973]4defined('BATCH_DOWNLOAD_ID') or define('BATCH_DOWNLOAD_ID', basename(dirname(__FILE__)));
5include_once(PHPWG_PLUGINS_PATH . BATCH_DOWNLOAD_ID . '/include/install.inc.php');
[16379]6
7function plugin_install() 
8{
[17656]9  batch_download_install();
[16379]10 
[17656]11  define('batch_download_installed', true);
[16379]12}
13
14function plugin_activate()
15{
[17656]16  if (!defined('batch_download_installed'))
[16379]17  {
[17656]18    batch_download_install();
[16379]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 
[19837]30  rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'download_archives/');
[16379]31}
32
[17656]33
34if (!function_exists('rrmdir'))
[16379]35{
[17656]36  function rrmdir($dir)
[16379]37  {
[17656]38    if (!is_dir($dir))
[16379]39    {
[17656]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 !== '..')
[16379]49      {
[17656]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        }
[16379]59      }
60    }
[17656]61   
62    return $return && @rmdir($dir);
[16379]63  }
[17656]64}
[16379]65
66?>
Note: See TracBrowser for help on using the repository browser.