示例#1
0
 function xpress_oninstall_base($module, $mydirname)
 {
     // transations on module install
     global $ret;
     // TODO :-D
     // for Cube 2.1
     if (defined('XOOPS_CUBE_LEGACY')) {
         $root =& XCube_Root::getSingleton();
         $root->mDelegateManager->add('Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success', 'xpress_message_append_oninstall');
         $root->mDelegateManager->add('Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Fail', 'xpress_message_append_oninstall_err');
         $ret = array();
     } else {
         if (!is_array($ret)) {
             $ret = array();
         }
     }
     $db =& Database::getInstance();
     $mid = $module->getVar('mid');
     if (defined('XOOPS_CUBE_LEGACY')) {
         $ret[] = "********************************* Install Log ********************************<br />";
     } else {
         $ret[] = '<h4 style="border-bottom: 1px dashed rgb(0, 0, 0); text-align: left; margin-bottom: 0px;">Install Log</h4>';
     }
     //xpress
     global $wpdb, $wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query, $wp_embed;
     global $xoops_config;
     define("WP_INSTALLING", true);
     define('WP_FIRST_INSTALL', true);
     // For WPMU2.8
     $site_url = XOOPS_URL . "/modules/" . $mydirname;
     $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
     $path = $mydirpath . '/';
     $site_name = ucfirst($mydirname) . ' ' . _MI_XP2_NAME;
     // permission and wordpress files check
     require_once $path . 'include/pre_check.php';
     if (!xp_permission_check($mydirname, $mydirpath)) {
         if (!defined('XOOPS_CUBE_LEGACY')) {
             $ret = $GLOBALS["err_log"];
             $ret[] = "<br /><span style=\"color:#ff0000;\">The uninstallation of the module is executed now. </span><br />";
             $ret[] = xoops_module_uninstall($mydirname);
         }
         return false;
     }
     // install WordPress
     if (file_exists($path . 'wp-load.php')) {
         require_once $path . 'wp-load.php';
     } else {
         require_once $path . 'wp-config.php';
     }
     include_once $mydirpath . '/wp-admin/upgrade-functions.php';
     wp_cache_flush();
     make_db_current_silent();
     $ret[] = "The data base of wordpress was made by prefix {$table_prefix}.<br />";
     $option_desc = __('WordPress web address');
     $wpdb->query("INSERT INTO {$wpdb->options} (blog_id, option_name,option_value, autoload) VALUES ('0', 'siteurl','{$site_url}', 'yes')");
     $wpdb->query("INSERT INTO {$wpdb->options} (blog_id, option_name,option_value, autoload) VALUES ('0', 'home','{$site_url}', 'yes')");
     populate_options();
     populate_roles();
     // create XPressME table
     $xp_prefix = preg_replace('/wordpress/', 'wp', $mydirname);
     $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_views';
     $charset_collate = '';
     if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
         if (!empty($wpdb->charset)) {
             $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
         }
         if (!empty($wpdb->collate)) {
             $charset_collate .= " COLLATE {$wpdb->collate}";
         }
     }
     $views_queries = "CREATE TABLE {$views_table} (\n  \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n  \t\tpost_id bigint(20) unsigned NOT NULL default '0',\n  \t\tpost_views bigint(20) unsigned NOT NULL default '0',\n  \t\tKEY post_id (post_id)\n\t\t){$charset_collate};";
     dbDelta($views_queries);
     $ret[] = "{$views_table} table of XPressME was made.<br />";
     $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_d3forum_link';
     $views_queries = "CREATE TABLE {$d3forum_link} (\n  \t\tcomment_ID bigint(20) unsigned NOT NULL default '0',\n  \t\tpost_id int(10) unsigned NOT NULL default '0' ,\n  \t\twp_post_ID bigint(20) unsigned NOT NULL default '0',\n  \t\tforum_id bigint(20) unsigned NOT NULL default '0',\n  \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n  \t\tKEY post_id (post_id)\n\t\t){$charset_collate};";
     dbDelta($views_queries);
     $ret[] = "{$d3forum_link} table of XPressME was made.<br />";
     $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_group_role';
     $views_queries = "CREATE TABLE {$group_role} (\n  \t\tgroupid smallint(5) unsigned NOT NULL default '0',\n  \t\tblog_id bigint(20) unsigned NOT NULL default '0',\n  \t\tname varchar(50)  NOT NULL default '' ,\n  \t\tdescription text  NOT NULL default '',\n  \t\tgroup_type varchar(50)  NOT NULL default '' ,\n\t\trole varchar(20)  NOT NULL default '' ,\n\t\tlogin_all smallint(5) unsigned NOT NULL default '0' ,\n  \t\tKEY groupid (groupid)\n\t\t){$charset_collate};";
     dbDelta($views_queries);
     $ret[] = "{$group_role} table of XPressME was made.<br />";
     $notify_reserve = XOOPS_DB_PREFIX . '_' . $xp_prefix . '_notify_reserve';
     $queries = "CREATE TABLE {$notify_reserve} (\n  \t\tnotify_reserve_id bigint(20) NOT NULL AUTO_INCREMENT ,\n  \t\tnotify_reserve_status varchar(20)  NOT NULL default '' ,\n  \t\tcategory text  NOT NULL default '',\n  \t\titem_id bigint(20) unsigned NOT NULL default '0',\n\t\tevent varchar(20) NOT NULL default '',\n\t\textra_tags_arry longtext NOT NULL default '' ,\n\t\tuser_list_arry longtext NOT NULL default '' ,\n  \t\tmodule_id smallint(5) unsigned NOT NULL default '0' ,\n  \t\tomit_user_id varchar(20) NOT NULL default '' ,\n  \t\tKEY notify_reserve_id (notify_reserve_id)\n\t\t)ENGINE=MyISAM";
     dbDelta($queries);
     $ret[] = "{$notify_reserve} table of XPressME was made.<br />";
     $sql = "INSERT INTO {$group_role} (groupid, role) VALUES (1, 'administrator')";
     $wpdb->query($sql);
     // make templates
     include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php';
     $t_mess = xpress_templates_make($mid, $mydirname);
     // Admin User Data write
     // Change uid field
     $wpdb->query("ALTER TABLE {$wpdb->posts} CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'");
     $user_name = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("uname") : 'admin';
     $email = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("email") : '*****@*****.**';
     $pass_md5 = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("pass") : '';
     add_filter('sanitize_user', "sanitize_user_multibyte", 10, 3);
     if (!function_exists('username_exists')) {
         require_once $mydirpath . '/wp-includes/registration-functions.php';
     }
     $user_id = username_exists($user_name);
     if (!$user_id) {
         $random_password = '******';
         $user_id = wp_create_user($user_name, $random_password, $email);
     } else {
         $random_password = __('User already exists.  Password inherited.');
     }
     $user = new WP_User($user_id);
     $user->set_role('administrator');
     'User ' . $user_name . ' of the administrator was made.';
     // over write xoops md5 password
     $sql = "UPDATE {$wpdb->users} SET user_pass ='******' WHERE ID = {$user_id}";
     $wpdb->query($sql);
     $ret[] = 'The password of XOOPS was copied.<br />';
     // Set Default data
     // make WordPress Default data
     if (function_exists('wp_install_defaults')) {
         wp_install_defaults($user_id);
     } else {
         wp_install_old_defaults($user_id);
     }
     $ret[] = 'The first sample post & comment was written.<br />';
     // Rewrite Option for Xpress
     $xoops_config_tbl = XOOPS_DB_PREFIX . '_config';
     $sql = "SELECT conf_value FROM  {$xoops_config_tbl} WHERE `conf_name` = 'default_TZ'";
     $xoops_default_TZ = $wpdb->get_var($sql);
     update_option('gmt_offset', $xoops_default_TZ);
     if (WPLANG == 'ja_EUC') {
         $setup_charset = 'EUC-JP';
     } elseif (WPLANG == 'ja_SJIS') {
         $setup_charset = 'Shift_JIS';
     } else {
         $setup_charset = 'UTF-8';
     }
     update_option("blog_charset", $setup_charset);
     update_option('blogname', $site_name);
     update_option('blogdescription', 'WordPress for XOOPS');
     update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']);
     update_option("ping_sites", "http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/");
     update_option("home", $site_url);
     update_option("siteurl", $site_url);
     update_option("what_to_show", "posts");
     update_option('default_pingback_flag', 0);
     $ret[] = 'The initial data was written in the data base of wordpress.<br />';
     update_option("template", "xpress_default");
     update_option("stylesheet", "xpress_default");
     $ret[] = 'The default theme of wordpress was set to xpress_default.<br />';
     //	update_option('uploads_use_yearmonth_folders', 1);
     update_option('upload_path', 'wp-content/uploads');
     // activate the xpressme plugin
     require_once dirname(__FILE__) . '/xpress_active_plugin.php';
     if (xpress_pulugin_activation('xpressme/xpressme.php')) {
         $ret[] = 'The xpressme plug-in was activated.<br />';
     } else {
         $GLOBALS["err_log"][] = '<span style="color:#ff0000;">failed in the activation of xpressme plug-in.</span><br />';
         return false;
     }
     $ret = array_merge($ret, $t_mess);
     return true;
 }
示例#2
0
function module_uninstall_now()
{
    global $xoopsSecurity, $xoopsConfig;
    $mod = rmc_server_var($_POST, 'module', '');
    if (!$xoopsSecurity->check()) {
        redirectMsg('modules.php', __('Sorry, this operation could not be completed!', 'rmcommon'), 1);
        die;
    }
    $module_handler = xoops_gethandler('module');
    if (!$module_handler->getByDirname($mod)) {
        redirectMsg('modules.php', sprintf(__('Module %s is not installed yet!', 'rmcommon'), $mod), 1);
        die;
    }
    $file = XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin/modulesadmin.php';
    if (file_exists($file)) {
        include_once $file;
    } else {
        include_once str_replace($xoopsConfig['language'], 'english', $file);
    }
    include_once XOOPS_ROOT_PATH . '/modules/system/admin/modulesadmin/modulesadmin.php';
    RMEvents::get()->run_event('rmcommon.uninstalling.module', $mod);
    $module_log = xoops_module_uninstall($mod);
    $module_log = RMEvents::get()->run_event('rmcommon.module.uninstalled', $module_log, $mod);
    RMFunctions::create_toolbar();
    RMTemplate::get()->add_style('modules.css', 'rmcommon');
    xoops_cp_header();
    $module = new XoopsModule();
    $module->loadInfo($mod, false);
    $log_title = sprintf(__('Uninstall log for %s', 'rmcommon'), $module ? $module->getInfo('name') : $mod);
    $action = rmc_server_var($_POST, 'action', '');
    include RMTemplate::get()->get_template('rmc_mod_log.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
示例#3
0
    $mod =& $module_handler->getByDirname($module);
    if ($mod->getInfo('image') != false && trim($mod->getInfo('image')) != '') {
        $msgs = '<img src="' . XOOPS_URL . '/modules/' . $mod->getVar('dirname') . '/' . trim($mod->getInfo('image')) . '" alt="" />';
    }
    $msgs .= '<br /><span style="font-size:smaller;";>' . $mod->getVar('name') . '</span><br /><br />' . _MD_AM_RUSUREUNINS;
    xoops_cp_header();
    xoops_token_confirm(array('module' => $module, 'op' => 'uninstall_ok', 'fct' => 'modulesadmin'), 'admin.php', $msgs, _YES);
    xoops_cp_footer();
    exit;
}
if ($op == 'uninstall_ok') {
    if (!xoops_confirm_validate()) {
        system_modulesadmin_error("Ticket Error");
    }
    $ret = array();
    $ret[] = xoops_module_uninstall($_POST['module']);
    $contents = xoops_module_get_admin_menu();
    if (!xoops_module_write_admin_menu($contents)) {
        $ret[] = "<p>" . _MD_AM_FAILWRITE . "</p>";
    }
    xoops_cp_header();
    if (count($ret) > 0) {
        foreach ($ret as $msg) {
            if ($msg != '') {
                echo $msg;
            }
        }
    }
    echo "<a href='admin.php?fct=modulesadmin'>" . _MD_AM_BTOMADMIN . "</a>";
    xoops_cp_footer();
    exit;
示例#4
0
     xoops_cp_header();
     // Define Stylesheet
     $xoTheme->addStylesheet(XOOPS_URL . '/modules/system/css/admin.css');
     // Define Breadcrumb and tips
     $xoBreadCrumb->addLink(_AM_SYSTEM_MODULES_ADMIN, system_adminVersion('modulesadmin', 'adminpath'));
     $xoBreadCrumb->addLink(_AM_SYSTEM_MODULES_UNINSTALL);
     $xoBreadCrumb->addHelp(system_adminVersion('modulesadmin', 'help') . '#delete');
     $xoBreadCrumb->render();
     // Display Question
     xoops_confirm(array('module' => $module, 'op' => 'uninstall_ok', 'fct' => 'modulesadmin'), 'admin.php', $msgs, _AM_SYSTEM_MODULES_UNINSTALL);
     // Call Footer
     xoops_cp_footer();
     break;
 case 'uninstall_ok':
     $ret = array();
     $ret[] = xoops_module_uninstall($module);
     // Flush cache files for cpanel GUIs
     xoops_load("cpanel", "system");
     XoopsSystemCpanel::flush();
     //Set active modules in cache folder
     xoops_setActiveModules();
     // Define main template
     $xoopsOption['template_main'] = 'system_header.html';
     // Call Header
     xoops_cp_header();
     // Define Stylesheet
     $xoTheme->addStylesheet(XOOPS_URL . '/modules/system/css/admin.css');
     // Define Breadcrumb and tips
     $xoBreadCrumb->addLink(_AM_SYSTEM_MODULES_ADMIN, system_adminVersion('modulesadmin', 'adminpath'));
     $xoBreadCrumb->addLink(_AM_SYSTEM_MODULES_UNINSTALL);
     $xoBreadCrumb->addHelp(system_adminVersion('modulesadmin', 'help') . '#delete');
示例#5
0
function module_uninstall_now()
{
    global $xoopsSecurity, $xoopsConfig, $rmTpl, $xoopsDB;
    $dir = RMHttpRequest::post('module', 'string', '');
    if (!$xoopsSecurity->check()) {
        redirectMsg('modules.php', __('Sorry, this operation could not be completed!', 'rmcommon'), 1);
        die;
    }
    $module_handler = xoops_gethandler('module');
    if (!($mod = $module_handler->getByDirname($dir))) {
        redirectMsg('modules.php', sprintf(__('Module %s is not installed yet!', 'rmcommon'), $mod), 1);
        die;
    }
    $file = XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin/modulesadmin.php';
    if (file_exists($file)) {
        include_once $file;
    } else {
        include_once str_replace($xoopsConfig['language'], 'english', $file);
    }
    include_once XOOPS_ROOT_PATH . '/modules/system/admin/modulesadmin/modulesadmin.php';
    RMEvents::get()->run_event('rmcommon.uninstalling.module', $mod);
    $module_log = xoops_module_uninstall($dir);
    // Remove comments
    $sql = "DELETE FROM " . $xoopsDB->prefix("mod_rmcommon_comments") . " WHERE id_obj='{$dir}'";
    if ($xoopsDB->queryF($sql)) {
        $module_log .= '<br><span class="text-success"><span class="fa fa-check"></span> Comments deleted successfully!</span>';
    } else {
        $module_log .= '<br><span class="text-danger"><span class="fa fa-exclamation-triangle"></span> Comments could not be deleted: ' . $xoopsDB->error() . '</span>';
    }
    // Remove notifications
    $sql = "DELETE FROM " . $xoopsDB->prefix("mod_rmcommon_notifications") . " WHERE element='{$dir}' AND `type`='module'";
    if ($xoopsDB->queryF($sql)) {
        $module_log .= '<br><span class="text-success"><span class="fa fa-check"></span> Notifications deleted successfully!</span>';
    } else {
        $module_log .= '<br><span class="text-danger"><span class="fa fa-exclamation-triangle"></span> Notifications could not be deleted: ' . $xoopsDB->error() . '</span>';
    }
    $module_log = RMEvents::get()->run_event('rmcommon.module.uninstalled', $module_log, $mod);
    //RMFunctions::create_toolbar();
    RMTemplate::get()->add_style('modules.min.css', 'rmcommon');
    RMBreadCrumb::get()->add_crumb(__('Modules Management', 'rmcommon'), 'modules.php');
    RMBreadCrumb::get()->add_crumb(sprintf(__('%s install log', 'rmcommon'), $mod->getVar('name')));
    $rmTpl->assign('xoops_pagetitle', sprintf(__('%s install log', 'rmcommon'), $mod->getVar('name')));
    xoops_cp_header();
    $module = new XoopsModule();
    $module->loadInfo($mod, false);
    $log_title = sprintf(__('Uninstall log for %s', 'rmcommon'), $module ? $module->getInfo('name') : $mod);
    $action = rmc_server_var($_POST, 'action', '');
    include RMTemplate::get()->get_template('rmc-modules-log.php', 'module', 'rmcommon');
    xoops_cp_footer();
}