function asb_xmlhttp() { global $mybb; if ($mybb->input['action'] != 'asb') { return; } // get the ASB core stuff require_once MYBB_ROOT . 'inc/plugins/asb/functions_addon.php'; require_once MYBB_ROOT . 'inc/plugins/asb/classes/xmlhttp.php'; // attempt to load the module and side box requested $module = new Addon_type($mybb->input['addon']); $sidebox = new Sidebox($mybb->input['id']); // we need both objects to continue if ($module->is_valid() && $sidebox->is_valid()) { // then call the module's AJAX method and echo its return value echo $module->do_xmlhttp($mybb->input['dateline'], $sidebox->get('settings'), $mybb->input['width'], $mybb->input['script']); } exit; }
function asb_admin_delete_addon() { global $mybb, $html, $lang; // info goof? if (!isset($mybb->input['addon']) || strlen(trim($mybb->input['addon'])) == 0) { flash_message($lang->asb_delete_addon_failure, 'error'); admin_redirect($html->url(array("action" => 'manage_modules'))); } $this_module = new Addon_type($mybb->input['addon']); if (!$this_module->remove()) { flash_message($lang->asb_delete_addon_failure, 'error'); } else { flash_message($lang->asb_delete_addon_success, 'success'); asb_cache_has_changed(); } admin_redirect($html->url(array("action" => 'manage_modules'))); }
function asb_activate() { // get the last cached version require_once MYBB_ROOT . 'inc/plugins/asb/functions_install.php'; // if we just upgraded . . . $old_version = asb_get_cache_version(); $info = asb_info(); if (version_compare($old_version, $info['version'], '<')) { global $lang; if (!$lang->asb) { $lang->load('asb'); } if (!class_exists('WildcardPluginInstaller')) { require_once MYBB_ROOT . 'inc/plugins/asb/classes/installer.php'; } $installer = new WildcardPluginInstaller(MYBB_ROOT . 'inc/plugins/asb/install_data.php'); $installer->install(); /* * remove a work-around for the MyBB 1.6.11 language bug * that was fixed in 1.6.12 */ if (version_compare($old_version, '2.0.5', '<')) { @unlink(MYBB_ROOT . 'inc/languages/english/admin/asb_addon.lang.php'); } /* * upgrade existing side boxes settings and removed old js files */ if (version_compare($old_version, '2.1', '<')) { require_once MYBB_ROOT . 'inc/plugins/asb/classes/forum.php'; $sideboxes = asb_get_all_sideboxes(); foreach ($sideboxes as $sidebox) { $settings = array(); foreach ((array) $sidebox->get('settings') as $name => $setting) { $settings[$name] = $setting['value']; } $sidebox->set('settings', $settings); $sidebox->save(); } for ($x = 1; $x < 4; $x++) { $module_name = 'example'; if ($x != 1) { $module_name .= $x; } $module = new Addon_type($module_name); $module->remove(); } asb_cache_has_changed(); $removed_files = array('jscripts/asb.js', 'jscripts/asb_xmlhttp.js', 'admin/jscripts/asb.js', 'admin/jscripts/asb_modal.js', 'admin/jscripts/asb_scripts.js', 'admin/jscripts/asb_sideboxes.js'); foreach ($removed_files as $file) { @unlink(MYBB_ROOT . $file); } } } asb_set_cache_version(); // change the permissions to on by default change_admin_permission('config', 'asb'); }