source: extensions/flickr2piwigo/maintain.inc.php @ 25803

Last change on this file since 25803 was 24815, checked in by mistic100, 11 years ago

fix bug with quotes, add batch manager prefilter

File size: 1.5 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4define(
5  'flickr2piwigo_default_config', 
6  serialize(array(
7    'api_key' => null,
8    'secret_key' => null,
9    ))
10  );
11
12
13function plugin_install() 
14{
15  global $conf;
16 
17  conf_update_param('flickr2piwigo', flickr2piwigo_default_config);
18 
19  mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
20}
21
22function plugin_activate()
23{
24  global $conf;
25
26  if (empty($conf['flickr2piwigo']))
27  {
28    conf_update_param('flickr2piwigo', flickr2piwigo_default_config);
29  }
30 
31  if (!file_exists(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/'))
32  {
33    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
34  }
35}
36
37function plugin_uninstall() 
38{
39  global $conf;
40 
41  pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "flickr2piwigo";');
42  unset($conf['flickr2piwigo']);
43 
44  rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/');
45}
46
47function rrmdir($dir)
48{
49  if (!is_dir($dir))
50  {
51    return false;
52  }
53  $dir = rtrim($dir, '/');
54  $objects = scandir($dir);
55  $return = true;
56 
57  foreach ($objects as $object)
58  {
59    if ($object !== '.' && $object !== '..')
60    {
61      $path = $dir.'/'.$object;
62      if (filetype($path) == 'dir') 
63      {
64        $return = $return && rrmdir($path); 
65      }
66      else 
67      {
68        $return = $return && @unlink($path);
69      }
70    }
71  }
72 
73  return $return && @rmdir($dir);
74} 
75
76?>
Note: See TracBrowser for help on using the repository browser.