1: <?php
2:
3: if (!class_exists('ProtectorRegistry')) {
4: exit('Registry not found');
5: }
6:
7: $registry = ProtectorRegistry::getInstance();
8: $mydirname = $registry->getEntry('mydirname');
9: $mydirpath = $registry->getEntry('mydirpath');
10: $language = $registry->getEntry('language');
11:
12:
13: eval(' function xoops_module_uninstall_' . $mydirname . '( $module ) { return protector_onuninstall_base( $module , "' . $mydirname . '" ) ; } ');
14:
15: if (!function_exists('protector_onuninstall_base')) {
16:
17: 18: 19: 20: 21: 22:
23: function protector_onuninstall_base($module, $mydirname)
24: {
25:
26:
27: global $ret;
28:
29:
30: if (defined('XOOPS_CUBE_LEGACY')) {
31: $root =& XCube_Root::getSingleton();
32: $root->mDelegateManager->add('Legacy.Admin.Event.ModuleUninstall.' . ucfirst($mydirname) . '.Success', 'protector_message_append_onuninstall');
33: $ret = array();
34: } else {
35: if (!is_array($ret)) {
36: $ret = array();
37: }
38: }
39:
40: $db = XoopsDatabaseFactory::getDatabaseConnection();
41: $mid = $module->getVar('mid');
42:
43:
44: $sql_file_path = __DIR__ . '/sql/mysql.sql';
45: $prefix_mod = $db->prefix() . '_' . $mydirname;
46: if (file_exists($sql_file_path)) {
47: $ret[] = 'SQL file found at <b>' . htmlspecialchars($sql_file_path) . '</b>.<br /> Deleting tables...<br>';
48: $sql_lines = file($sql_file_path);
49: foreach ($sql_lines as $sql_line) {
50: if (preg_match('/^CREATE TABLE \`?([a-zA-Z0-9_-]+)\`? /i', $sql_line, $regs)) {
51: $sql = 'DROP TABLE ' . addslashes($prefix_mod . '_' . $regs[1]);
52: if (!$db->query($sql)) {
53: $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>' . htmlspecialchars($prefix_mod . '_' . $regs[1]) . '<b>.</span><br>';
54: } else {
55: $ret[] = 'Table <b>' . htmlspecialchars($prefix_mod . '_' . $regs[1]) . '</b> dropped.<br>';
56: }
57: }
58: }
59: }
60:
61:
62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75:
76:
77: return true;
78: }
79:
80: 81: 82: 83:
84: function protector_message_append_onuninstall(&$module_obj, &$log)
85: {
86: if (is_array(@$GLOBALS['ret'])) {
87: foreach ($GLOBALS['ret'] as $message) {
88: $log->add(strip_tags($message));
89: }
90: }
91:
92:
93: }
94: }
95: