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

Last change on this file since 17909 was 17656, checked in by mistic100, 12 years ago

consolidate upgrade process, always use original filenames

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