-
Notifications
You must be signed in to change notification settings - Fork 1
/
maintain.class.php
65 lines (54 loc) · 1.34 KB
/
maintain.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
class instagram2piwigo_maintain extends PluginMaintain
{
private $default_conf = array(
'api_key' => null,
'secret_key' => null,
);
function install($plugin_version, &$errors=array())
{
global $conf;
if (empty($conf['Instagram2Piwigo']))
{
conf_update_param('Instagram2Piwigo', $this->default_conf, true);
}
mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
}
function update($old_version, $new_version, &$errors=array())
{
$this->install($new_version, $errors);
}
function uninstall()
{
global $conf;
conf_delete_param('Instagram2Piwigo');
self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_cache/');
}
static function rrmdir($dir)
{
if (!is_dir($dir))
{
return false;
}
$dir = rtrim($dir, '/');
$objects = scandir($dir);
$return = true;
foreach ($objects as $object)
{
if ($object !== '.' && $object !== '..')
{
$path = $dir.'/'.$object;
if (filetype($path) == 'dir')
{
$return = $return && self::rrmdir($path);
}
else
{
$return = $return && @unlink($path);
}
}
}
return $return && @rmdir($dir);
}
}