source: extensions/GThumb/maintain.inc.php @ 14974

Last change on this file since 14974 was 13652, checked in by patdenice, 12 years ago

Compatible with Piwigo 2.4

File size: 1.2 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5function plugin_install()
6{
7  include(dirname(__FILE__).'/config_default.inc.php');
8
9  $query = '
10INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
11VALUES ("GThumb" , "'.addslashes(serialize($config_default)).'" , "GThumb plugin parameters");';
12  pwg_query($query);
13}
14
15function plugin_uninstall()
16{
17  if (is_dir(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb'))
18  {
19    gtdeltree(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb');
20  }
21 
22  $query = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="GThumb" LIMIT 1;';
23  pwg_query($query);
24}
25
26function plugin_activate($plugin_id, $version)
27{
28  if (is_dir(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb'))
29  {
30    gtdeltree(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'GThumb');
31  }
32}
33
34function gtdeltree($path)
35{
36  if (is_dir($path))
37  {
38    $fh = opendir($path);
39    while ($file = readdir($fh))
40    {
41      if ($file != '.' and $file != '..')
42      {
43        $pathfile = $path . '/' . $file;
44        if (is_dir($pathfile))
45        {
46          gtdeltree($pathfile);
47        }
48        else
49        {
50          @unlink($pathfile);
51        }
52      }
53    }
54    closedir($fh);
55    return @rmdir($path);
56  }
57}
58
59?>
Note: See TracBrowser for help on using the repository browser.