source: extensions/GDThumb/maintain.class.php @ 31813

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

GDThumb 1.0.12

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