|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* uninstall.php - cleanup on module uninstall |
|
4
|
|
|
* |
|
5
|
|
|
* @author XOOPS Module Development Team |
|
6
|
|
|
* @copyright {@link http://xoops.org 2001-2016 XOOPS Project} |
|
7
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
|
8
|
|
|
* @link http://xoops.org XOOPS |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Prepares system prior to attempting to uninstall module |
|
14
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
|
15
|
|
|
* |
|
16
|
|
|
* @return bool true if ready to uninstall, false if not |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
function xoops_module_pre_uninstall_xfguestbook(XoopsModule $module) |
|
|
|
|
|
|
20
|
|
|
{ |
|
21
|
|
|
// Do some synchronization |
|
22
|
|
|
return true; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* |
|
27
|
|
|
* Performs tasks required during uninstallation of the module |
|
28
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
|
29
|
|
|
* |
|
30
|
|
|
* @return bool true if uninstallation successful, false if not |
|
31
|
|
|
*/ |
|
32
|
|
|
function xoops_module_uninstall_xfguestbook(XoopsModule $module) |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
return true; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
//======================================================= |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
|
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param XoopsModule $module |
|
47
|
|
|
* |
|
48
|
|
|
* @return bool |
|
49
|
|
|
*/ |
|
50
|
|
|
function xoops_module_uninstall_XXXX(XoopsModule $module) |
|
|
|
|
|
|
51
|
|
|
{ |
|
52
|
|
|
// global $xoopsDB,$xoopsConfig; |
|
|
|
|
|
|
53
|
|
|
// |
|
54
|
|
|
// nothing to do yet |
|
55
|
|
|
return true; |
|
56
|
|
|
|
|
57
|
|
|
//routine to delete a cache directory |
|
58
|
|
|
/* |
|
|
|
|
|
|
59
|
|
|
$cacheDir = XOOPS_ROOT_PATH . '/uploads/shoutbox'; |
|
60
|
|
|
//Always check if a directory exists prior to creation |
|
61
|
|
|
if (!is_dir($cacheDir)) { |
|
62
|
|
|
return true; |
|
63
|
|
|
} else { |
|
64
|
|
|
return rmdirr($cacheDir); // see the function below |
|
65
|
|
|
} |
|
66
|
|
|
*/ |
|
67
|
|
|
|
|
68
|
|
|
//------------- example from user log -------------- |
|
69
|
|
|
/* |
|
|
|
|
|
|
70
|
|
|
$logsetObj = UserlogSetting::getInstance(); |
|
71
|
|
|
|
|
72
|
|
|
return $logsetObj->cleanCache(); // delete all settings caches |
|
73
|
|
|
|
|
74
|
|
|
*/ |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Delete a file, or a folder and its contents |
|
79
|
|
|
* |
|
80
|
|
|
* @author Aidan Lister <[email protected]> |
|
81
|
|
|
* @param string $dirname The directory to delete |
|
82
|
|
|
* @return bool Returns true on success, false on failure |
|
83
|
|
|
*/ |
|
84
|
|
|
|
|
85
|
|
|
function rmdirr($dirname) |
|
86
|
|
|
{ |
|
87
|
|
|
// Simple delete for a file |
|
88
|
|
|
if (is_file($dirname)) { |
|
89
|
|
|
return unlink($dirname); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
// Loop through the folder |
|
93
|
|
|
$dir = dir($dirname); |
|
94
|
|
|
while (false !== $entry = $dir->read()) { |
|
95
|
|
|
// Skip pointers |
|
96
|
|
|
if ($entry == '.' || $entry == '..') { |
|
97
|
|
|
continue; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
// Deep delete directories |
|
101
|
|
|
if (is_dir("$dirname/$entry")) { |
|
102
|
|
|
rmdirr("$dirname/$entry"); |
|
103
|
|
|
} else { |
|
104
|
|
|
unlink("$dirname/$entry"); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
// Clean up |
|
109
|
|
|
$dir->close(); |
|
110
|
|
|
|
|
111
|
|
|
return rmdir($dirname); |
|
112
|
|
|
} |
|
113
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.