source: extensions/GDThumb/maintain.inc.php @ 31810

Last change on this file since 31810 was 30225, checked in by SergeD, 9 years ago

GDThumb 1.0.12

File size: 1.3 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5class GDThumb_maintain extends PluginMaintain {
6  private $installed = false;
7 
8  function install($plugin_version, &$errors=array()) {
9    include(dirname(__FILE__).'/config_default.inc.php');
10    global $conf;
11    if (empty($conf['gdThumb'])):
12      $conf['gdThumb'] = serialize($config_default);
13      conf_update_param('gdThumb', $conf['gdThumb']);
14    endif;
15
16    $this->installed = true;
17  }
18
19  function activate($plugin_version, &$errors=array()) {
20    if (!$this->installed):
21      $this->install($plugin_version, $errors);
22      $this->cleanUp();
23    endif;
24  }
25
26  function deactivate() {
27  }
28
29  function uninstall() {
30    $this->cleanUp();
31    conf_delete_param('gdThumb');
32  }
33
34  private function cleanUp() {
35    if (is_dir(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'GDThumb')):
36      $this->gtdeltree(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'GDThumb');
37    endif;
38  }
39
40  private function gtdeltree($path) {
41    if (is_dir($path)):
42      $fh = opendir($path);
43      while ($file = readdir($fh)) {
44        if ($file != '.' and $file != '..'):
45          $pathfile = $path . '/' . $file;
46          if (is_dir($pathfile)):
47            gtdeltree($pathfile);
48          else:
49            @unlink($pathfile);
50          endif;
51        endif;
52      }
53      closedir($fh);
54      return @rmdir($path);
55    endif;
56  }
57
58}
59?>
Note: See TracBrowser for help on using the repository browser.