Last change
on this file since 22831 was
19831,
checked in by mistic100, 12 years ago
|
make sure temp folder is created on the right place
|
File size:
1.5 KB
|
Rev | Line | |
---|
[16063] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | define( |
---|
| 5 | 'flickr2piwigo_default_config', |
---|
| 6 | serialize(array( |
---|
| 7 | 'api_key' => null, |
---|
| 8 | 'secret_key' => null, |
---|
| 9 | )) |
---|
| 10 | ); |
---|
| 11 | |
---|
[16071] | 12 | |
---|
[16063] | 13 | function plugin_install() |
---|
| 14 | { |
---|
| 15 | global $conf; |
---|
[16071] | 16 | |
---|
[16063] | 17 | conf_update_param('flickr2piwigo', flickr2piwigo_default_config); |
---|
[16071] | 18 | |
---|
[19831] | 19 | mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); |
---|
[16063] | 20 | } |
---|
| 21 | |
---|
| 22 | function plugin_activate() |
---|
| 23 | { |
---|
| 24 | global $conf; |
---|
| 25 | |
---|
| 26 | if (empty($conf['flickr2piwigo'])) |
---|
| 27 | { |
---|
| 28 | conf_update_param('flickr2piwigo', flickr2piwigo_default_config); |
---|
| 29 | } |
---|
| 30 | |
---|
[19831] | 31 | if (!file_exists(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/')) |
---|
[16063] | 32 | { |
---|
[19831] | 33 | mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); |
---|
[16063] | 34 | } |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | function plugin_uninstall() |
---|
| 38 | { |
---|
[17476] | 39 | global $conf; |
---|
| 40 | |
---|
[16063] | 41 | pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "flickr2piwigo" LIMIT 1;'); |
---|
[16071] | 42 | |
---|
[19831] | 43 | rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/'); |
---|
[16063] | 44 | } |
---|
| 45 | |
---|
[16071] | 46 | function 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 | |
---|
[16063] | 75 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.