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

Last change on this file since 20461 was 19831, checked in by mistic100, 11 years ago

make sure temp folder is created on the right place

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" LIMIT 1;');
42 
43  rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/');
44}
45
46function rrmdir($dir)
47{
48  if (!is_dir($dir))
49  {
50    return false;
51  }
52  $dir = rtrim($dir, '/');
53  $objects = scandir($dir);
54  $return = true;
55 
56  foreach ($objects as $object)
57  {
58    if ($object !== '.' && $object !== '..')
59    {
60      $path = $dir.'/'.$object;
61      if (filetype($path) == 'dir') 
62      {
63        $return = $return && rrmdir($path); 
64      }
65      else 
66      {
67        $return = $return && @unlink($path);
68      }
69    }
70  }
71 
72  return $return && @rmdir($dir);
73} 
74
75?>
Note: See TracBrowser for help on using the repository browser.