| 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: |
|
| 28: | global $ret;
|
| 29: |
|
| 30: | if (!is_array($ret)) {
|
| 31: | $ret = array();
|
| 32: | }
|
| 33: |
|
| 34: |
|
| 35: | $db = XoopsDatabaseFactory::getDatabaseConnection();
|
| 36: | $mid = $module->getVar('mid');
|
| 37: | if (!is_array($ret)) {
|
| 38: | $ret = array();
|
| 39: | }
|
| 40: |
|
| 41: |
|
| 42: | $sql_file_path = __DIR__ . '/sql/mysql.sql';
|
| 43: | $prefix_mod = $db->prefix() . '_' . $mydirname;
|
| 44: | if (file_exists($sql_file_path)) {
|
| 45: | $ret[] = 'SQL file found at <b>' . htmlspecialchars($sql_file_path, ENT_QUOTES) . '</b>.<br /> Deleting tables...<br>';
|
| 46: | $sql_lines = file($sql_file_path);
|
| 47: | foreach ($sql_lines as $sql_line) {
|
| 48: | if (preg_match('/^CREATE TABLE \`?([a-zA-Z0-9_-]+)\`? /i', $sql_line, $regs)) {
|
| 49: | $sql = 'DROP TABLE ' . addslashes($prefix_mod . '_' . $regs[1]);
|
| 50: | if (!$db->query($sql)) {
|
| 51: | $ret[] = '<span style="color:#ff0000;">ERROR: Could not drop table <b>' . htmlspecialchars($prefix_mod . '_' . $regs[1], ENT_QUOTES) . '<b>.</span><br>';
|
| 52: | } else {
|
| 53: | $ret[] = 'Table <b>' . htmlspecialchars($prefix_mod . '_' . $regs[1], ENT_QUOTES) . '</b> dropped.<br>';
|
| 54: | }
|
| 55: | }
|
| 56: | }
|
| 57: | }
|
| 58: |
|
| 59: |
|
| 60: |
|
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: |
|
| 75: |
|
| 76: | return true;
|
| 77: | }
|
| 78: |
|
| 79: | |
| 80: | |
| 81: | |
| 82: |
|
| 83: | function protector_message_append_onuninstall(&$module_obj, &$log)
|
| 84: | {
|
| 85: | if (isset($GLOBALS['ret']) && is_array($GLOBALS['ret'])) {
|
| 86: | foreach ($GLOBALS['ret'] as $message) {
|
| 87: | $log->add(strip_tags($message));
|
| 88: | }
|
| 89: | }
|
| 90: |
|
| 91: |
|
| 92: | }
|
| 93: | }
|
| 94: | |