예제 #1
0
header('Content-type: text/plain');
if (!file_exists($FILE_BASE . '/data_custom/addon_files.txt')) {
    exit("File missing : <br />" . $FILE_BASE . '/data_custom/addon_files.txt');
}
if (!file_exists($FILE_BASE . '/data_custom/addons-sheet.csv')) {
    exit("File missing : <br />" . $FILE_BASE . '/data_custom/addons-sheet.csv');
}
@set_time_limit(0);
$only = get_param('only', NULL);
if (get_param_integer('export_bundled_addons', 0) == 1) {
    $addons = find_all_hooks('systems', 'addon_registry');
    foreach (array_keys($addons) as $name) {
        if ($only !== NULL && $only !== $name) {
            continue;
        }
        $addon_row = read_addon_info($name);
        // Archive it off to exports/mods
        if (file_exists(get_file_base() . '/sources/hooks/systems/addon_registry/' . $name . '.php')) {
            $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $name)) . '.tar';
        } else {
            $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $name)) . date('-dmY-Hm', time()) . '.tar';
        }
        $new_addon_files = array();
        foreach ($addon_row['addon_files'] as $_file) {
            if (substr($_file, -9) != '.editfrom') {
                // This would have been added back in automatically
                $new_addon_files[] = $_file;
            }
        }
        create_addon($file, $new_addon_files, $addon_row['addon_name'], implode(',', $addon_row['addon_incompatibilities']), implode(',', $addon_row['addon_dependencies']), $addon_row['addon_author'], $addon_row['addon_organisation'], $addon_row['addon_version'], $addon_row['addon_description'], 'exports/mods');
    }
예제 #2
0
 /**
  * UI for a setup wizard step (done).
  *
  * @return tempcode		The UI
  */
 function step10()
 {
     $title = get_page_title('SETUP_WIZARD_STEP', true, array(integer_format(10), integer_format(10)));
     $GLOBALS['NO_QUERY_LIMIT'] = true;
     require_code('abstract_file_manager');
     force_have_afm_details();
     if (function_exists('set_time_limit')) {
         @set_time_limit(600);
     }
     require_code('config2');
     require_code('menus2');
     require_code('themes2');
     require_lang('zones');
     $header_text = post_param('header_text');
     $name = post_param('site_name');
     $theme = substr(preg_replace('#[^A-Za-z\\d]#', '_', $name), 0, 40);
     $installprofile = post_param('installprofile', '');
     if ($installprofile != '') {
         // Simplify down to a single menu
         foreach (array('main_community', 'main_content', 'main_features', 'main_website', 'root_website') as $merge_item) {
             $GLOBALS['SITE_DB']->query_update('menu_items', array('i_menu' => 'site'), array('i_menu' => $merge_item));
         }
         $duplicates = $GLOBALS['SITE_DB']->query_select('menu_items', array('id', 'COUNT(*) AS cnt'), array('i_menu' => 'site'), 'GROUP BY i_url');
         foreach ($duplicates as $duplicate) {
             if ($duplicate['cnt'] > 1) {
                 delete_menu_item($duplicate['id']);
             }
         }
         delete_menu_item_simple('site:');
         // Remove panel_top
         if (addon_installed('redirects_editor')) {
             $GLOBALS['SITE_DB']->query_delete('redirects', array('r_to_page' => 'panel_top'));
         }
         $fullpath = get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_top.txt';
         if (file_exists($fullpath)) {
             @copy($fullpath, $fullpath . '.' . strval(time()));
         }
         $myfile = @fopen($fullpath, 'wt');
         if ($myfile !== false) {
             fwrite($myfile, '');
             fclose($myfile);
             fix_permissions($fullpath);
             sync_file($fullpath);
         }
         // Run any specific code for the profile
         $object = mixed();
         if (is_file(get_file_base() . '/sources/hooks/modules/admin_setupwizard_installprofiles/' . $installprofile . '.php') || is_file(get_file_base() . '/sources_custom/hooks/modules/admin_setupwizard_installprofiles/' . $installprofile . '.php')) {
             require_code('hooks/modules/admin_setupwizard_installprofiles/' . $installprofile);
             $object = object_factory('Hook_admin_setupwizard_installprofiles_' . $installprofile, true);
         }
         if (!is_null($object)) {
             $object->install_code();
             $installprofileblocks = $object->default_blocks();
         } else {
             $installprofileblocks = array();
         }
     } else {
         $installprofileblocks = array();
     }
     if (post_param_integer('skip_8', 0) == 0 && function_exists('imagecreatefromstring') && addon_installed('themewizard')) {
         require_code('themewizard');
         // Make theme
         global $IMG_CODES;
         $old_img_codes_site = $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'path'), array('theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'lang' => user_lang()));
         if (!file_exists(get_custom_file_base() . '/themes/' . $theme)) {
             make_theme($theme, 'default', 'equations', post_param('seed_hex'), true, post_param_integer('dark', 0) == 1);
         }
         foreach (array($theme, 'default') as $logo_save_theme) {
             $logo = generate_logo($name, $header_text, false, $logo_save_theme, 'logo-template');
             $path = 'themes/' . $logo_save_theme . '/images_custom/-logo.png';
             @imagepng($logo, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
             actual_edit_theme_image('logo/-logo', $logo_save_theme, get_site_default_lang(), 'logo/-logo', $path, true);
             if (addon_installed('collaboration_zone')) {
                 actual_edit_theme_image('logo/collaboration-logo', $logo_save_theme, get_site_default_lang(), 'logo/collaboration-logo', $path, true);
             }
             imagedestroy($logo);
             $logo = generate_logo($name, $header_text, false, $logo_save_theme, 'trimmed-logo-template');
             $path = 'themes/' . $logo_save_theme . '/images_custom/trimmed-logo.png';
             @imagepng($logo, get_custom_file_base() . '/' . $path) or intelligent_write_error($path);
             actual_edit_theme_image('logo/trimmed-logo', $logo_save_theme, get_site_default_lang(), 'logo/trimmed-logo', $path, true);
             imagedestroy($logo);
         }
         $myfile = fopen(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini', 'wt');
         fwrite($myfile, 'title=' . $name . chr(10));
         fwrite($myfile, 'description=' . do_lang('NA') . chr(10));
         if (fwrite($myfile, 'author=ocPortal' . chr(10)) == 0) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         sync_file(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini');
         $IMG_CODES['site'] = $old_img_codes_site;
         // Just so it renders with the old theme
     }
     // Set options
     if (post_param_integer('skip_3', 0) == 0) {
         set_option('site_name', $name);
         set_option('copyright', 'Copyright &copy; ' . $name . ' ' . date('Y'));
         set_option('description', post_param('description'));
         set_option('site_scope', post_param('site_scope'));
         set_option('copyright', post_param('copyright'));
         set_option('staff_address', post_param('staff_address'));
         set_option('keywords', post_param('keywords'));
         set_option('google_analytics', post_param('google_analytics'));
         set_option('fixed_width', post_param('fixed_width', '0'));
         $a = $GLOBALS['SITE_DB']->query_value('zones', 'zone_header_text', array('zone_name' => ''));
         lang_remap($a, $header_text);
         $b = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_header_text', array('zone_name' => 'site'));
         if (!is_null($b)) {
             lang_remap($b, $header_text);
         }
     }
     if (post_param_integer('skip_9', 0) == 0) {
         set_option('site_closed', strval(post_param_integer('site_closed', 0)));
         set_option('closed', post_param('closed', ''));
     }
     // Set addons
     if (post_param_integer('skip_4', 0) == 0 && get_file_base() == get_custom_file_base()) {
         require_lang('addons');
         require_code('addons');
         $addons_installed = find_installed_addons();
         $uninstalling = array();
         foreach ($addons_installed as $addon_row) {
             if (post_param_integer('addon_' . $addon_row['addon_name'], 0) == 0) {
                 $uninstalling[$addon_row['addon_name']] = $addon_row;
             }
         }
         if (!file_exists(get_file_base() . '/.svn')) {
             do {
                 $cnt = count($uninstalling);
                 foreach ($addons_installed as $addon_row) {
                     if (array_key_exists($addon_row['addon_name'], $uninstalling)) {
                         $addon_row += read_addon_info($addon_row['addon_name']);
                         $addon_row['addon_author'] = '';
                         // Fudge, to stop it dying on warnings for official addons
                         // Check dependencies
                         $dependencies = $addon_row['addon_dependencies_on_this'];
                         foreach (array_keys($uninstalling) as $d) {
                             if (in_array($d, $dependencies)) {
                                 // Can mark this dependency as irrelevant, as we are uninstalling the addon for it anyway
                                 unset($dependencies[array_search($d, $dependencies)]);
                             }
                         }
                         if (count($dependencies) != 0) {
                             unset($uninstalling[$addon_row['addon_name']]);
                         }
                     }
                 }
             } while ($cnt != count($uninstalling));
             // Dependency chains can be complex, so loop until we're stopped finding anything changing
             foreach ($uninstalling as $addon_row) {
                 // Archive it off to exports/addons
                 if ($addon_row['addon_files'] != '') {
                     $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $addon_row['addon_name'])) . '.tar';
                     create_addon($file, explode(chr(10), $addon_row['addon_files']), $addon_row['addon_name'], implode(',', $addon_row['addon_incompatibilities']), implode(',', $addon_row['addon_dependencies']), $addon_row['addon_author'], $addon_row['addon_organisation'], $addon_row['addon_version'], $addon_row['addon_description'], 'imports/addons');
                 }
                 uninstall_addon($addon_row['addon_name']);
             }
         }
     }
     // Set features
     if (post_param_integer('skip_5', 0) == 0) {
         $hooks = find_all_hooks('modules', 'admin_setupwizard');
         foreach (array_keys($hooks) as $hook) {
             if (post_param_integer('addon_' . $hook, 0) == 1) {
                 $path = get_file_base() . '/sources_custom/modules/systems/admin_setupwizard/' . filter_naughty_harsh($hook) . '.php';
                 if (!file_exists($path)) {
                     $path = get_file_base() . '/sources/hooks/modules/admin_setupwizard/' . filter_naughty_harsh($hook) . '.php';
                 }
                 $_hook_bits = extract_module_functions($path, array('set_fields'));
                 if (is_array($_hook_bits[0])) {
                     call_user_func_array($_hook_bits[0][0], $_hook_bits[0][1]);
                 } else {
                     @eval($_hook_bits[0]);
                 }
             }
         }
         set_option('show_content_tagging', post_param('show_content_tagging', '0'));
         set_option('show_content_tagging_inline', post_param('show_content_tagging_inline', '0'));
         set_option('show_screen_actions', post_param('show_screen_actions', '0'));
     }
     // Zone structure
     $collapse_zones = post_param_integer('collapse_user_zones', 0) == 1;
     if (post_param_integer('skip_5', 0) == 0) {
         require_code('config2');
         set_option('collapse_user_zones', strval($collapse_zones));
         /*if (addon_installed('redirects_editor')) Old method
         		{
         			if ($collapse_zones)
         			{
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'panel_left','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'panel_left','r_from_zone'=>'site','r_to_page'=>'panel_left','r_to_zone'=>'','r_is_transparent'=>1));
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'panel_right','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'panel_right','r_from_zone'=>'site','r_to_page'=>'panel_right','r_to_zone'=>'','r_is_transparent'=>1));
         				$test=$GLOBALS['SITE_DB']->query_value_null_ok('redirects','r_from_page',array('r_from_page'=>'start','r_from_zone'=>'site'));
         				if (is_null($test)) $GLOBALS['SITE_DB']->query_insert('redirects',array('r_from_page'=>'start','r_from_zone'=>'site','r_to_page'=>'start','r_to_zone'=>'','r_is_transparent'=>1));
         			} else
         			{
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'panel_left','r_from_zone'=>'site','r_to_page'=>'panel_left','r_to_zone'=>''),'',1);
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'panel_right','r_from_zone'=>'site','r_to_page'=>'panel_right','r_to_zone'=>''),'',1);
         				$GLOBALS['SITE_DB']->query_delete('redirects',array('r_from_page'=>'start','r_from_zone'=>'site','r_to_page'=>'start','r_to_zone'=>''),'',1);
         			}
         		}*/
         if (post_param_integer('guest_zone_access', 0) == 1) {
             $guest_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($GLOBALS['FORUM_DRIVER']->get_guest_id());
             $test = $GLOBALS['SITE_DB']->query_value_null_ok('group_zone_access', 'zone_name', array('zone_name' => 'site', 'group_id' => $guest_groups[0]));
             if (is_null($test)) {
                 $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => 'site', 'group_id' => $guest_groups[0]));
             }
         }
     }
     // Rules
     if (post_param_integer('skip_7', 0) == 0) {
         $fullpath = get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/rules.txt';
         if (file_exists($fullpath)) {
             @copy($fullpath, $fullpath . '.' . strval(time()));
             fix_permissions($fullpath . '.' . strval(time()));
             sync_file($fullpath . '.' . strval(time()));
         }
         $myfile = @fopen($fullpath, 'wt') or intelligent_write_error(get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/rules.txt');
         $rf = $this->get_rules_file(post_param('rules'));
         if (fwrite($myfile, $rf) < strlen($rf)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         fix_permissions($fullpath);
         sync_file($fullpath);
     }
     $block_options = mixed();
     if ($installprofile != '' && !is_null($object)) {
         $block_options = $object->block_options();
     }
     // Blocks
     if (post_param_integer('skip_6', 0) == 0) {
         require_code('setupwizard');
         $page_structure = _get_zone_pages($installprofileblocks, $block_options, $collapse_zones, $installprofile);
         foreach ($page_structure as $zone => $zone_pages) {
             // Start
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/start.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = @fopen($fullpath, 'wt') or intelligent_write_error($fullpath);
             if ($myfile !== false) {
                 if ($zone_pages['start'] != '') {
                     if (fwrite($myfile, $zone_pages['start']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
             // Left
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_left.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = @fopen($fullpath, 'wt');
             if ($myfile !== false) {
                 if ($zone_pages['left'] != '') {
                     if (fwrite($myfile, $zone_pages['left']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
             // Right
             $fullpath = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_right.txt';
             if (file_exists($fullpath)) {
                 @copy($fullpath, $fullpath . '.' . strval(time()));
             }
             $myfile = fopen($fullpath, 'wt');
             if ($myfile !== false) {
                 if ($zone_pages['right'] != '') {
                     if (fwrite($myfile, $zone_pages['right']) == 0) {
                         warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                     }
                 }
                 fclose($myfile);
                 fix_permissions($fullpath);
                 sync_file($fullpath);
             }
         }
     }
     // We're done
     set_value('setup_wizard_completed', '1');
     // Clear some cacheing
     require_code('view_modes');
     require_code('zones3');
     erase_comcode_page_cache();
     erase_tempcode_cache();
     //persistant_cache_delete('OPTIONS');  Done by set_option
     persistant_cache_empty();
     erase_cached_templates();
     //breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang_tempcode('START'))));
     //breadcrumb_set_self(do_lang_tempcode('SETUP_WIZARD_STEP',integer_format(10),integer_format(10)));
     $url = build_url(array('page' => '_SELF', 'type' => 'step11'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
예제 #3
0
/**
 * Get information for the user relating to an addon that they are intending to uninstall.
 *
 * @param  string			Name of the addon
 * @param  ?array			List of addons that we're currently uninstalling (so dependencies from these are irrelevant). (NULL: none)
 * @param  ?array			Addon details. (NULL: load in function)
 * @return array			Pair: warnings, files
 */
function inform_about_addon_uninstall($name, $also_uninstalling = NULL, $addon_row = NULL)
{
    if (is_null($also_uninstalling)) {
        $also_uninstalling = array();
    }
    // Read/show info
    if (is_null($addon_row)) {
        $addon_row = read_addon_info($name);
    }
    $files = new ocp_tempcode();
    // The files can come in as either a newline-separated string or an array.
    // If its an array then we use it as-is, if it's a string then we explode it first.
    if (is_array($addon_row['addon_files'])) {
        $loopable = $addon_row['addon_files'];
    } else {
        $loopable = explode(chr(10), $addon_row['addon_files']);
    }
    foreach ($loopable as $i => $filename) {
        $files->attach(do_template('ADDON_INSTALL_FILES', array('I' => strval($i), 'DISABLED' => true, 'PATH' => $filename)));
    }
    // Check dependencies
    $dependencies = $addon_row['addon_dependencies_on_this'];
    foreach ($also_uninstalling as $d) {
        if (in_array($d, $dependencies)) {
            unset($dependencies[array_search($d, $dependencies)]);
        }
    }
    $warnings = new ocp_tempcode();
    $_dependencies_str = new ocp_tempcode();
    foreach ($dependencies as $in) {
        if (!$_dependencies_str->is_empty()) {
            $_dependencies_str->attach(do_lang_tempcode('LIST_SEP'));
        }
        $_dependencies_str->attach(escape_html($in));
    }
    if (count($dependencies) != 0) {
        if ($addon_row['addon_author'] == 'Core Team') {
            $post_fields = build_keep_post_fields();
            foreach ($dependencies as $in) {
                $post_fields->attach(form_input_hidden('uninstall_' . $in, $in));
            }
            if (get_param('type', 'misc') == 'addon_uninstall') {
                $post_fields->attach(form_input_hidden('uninstall_' . $name, $name));
                $url = static_evaluate_tempcode(build_url(array('page' => '_SELF', 'type' => 'multi_action'), '_SELF'));
            } else {
                $url = get_self_url(true);
            }
            warn_exit(do_lang_tempcode('_ADDON_WARNING_PRESENT_DEPENDENCIES', $_dependencies_str->evaluate(), escape_html($name), array(escape_html($url), $post_fields)));
        } else {
            $warnings->attach(do_template('ADDON_INSTALL_WARNING', array('WARNING' => do_lang_tempcode('ADDON_WARNING_PRESENT_DEPENDENCIES', $_dependencies_str, escape_html($name)))));
        }
    }
    return array($warnings, $files);
}
예제 #4
0
 /**
  * The UI to uninstall an addon.
  *
  * @return tempcode		The UI
  */
 function _addon_uninstall()
 {
     $title = get_page_title('UNINSTALL_ADDON');
     require_code('abstract_file_manager');
     force_have_afm_details();
     $name = post_param('name');
     $addon_row = read_addon_info($name);
     // Archive it off to exports/mods
     if (file_exists(get_file_base() . '/sources/hooks/systems/addon_registry/' . $name . '.php')) {
         $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $name)) . '.tar';
     } else {
         $file = preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $name)) . date('-dmY-Hm', time()) . '.tar';
     }
     $new_addon_files = array();
     foreach ($addon_row['addon_files'] as $_file) {
         if (substr($_file, -9) != '.editfrom') {
             // This would have been added back in automatically
             $new_addon_files[] = $_file;
         }
     }
     create_addon($file, $new_addon_files, $addon_row['addon_name'], implode(',', $addon_row['addon_incompatibilities']), implode(',', $addon_row['addon_dependencies']), $addon_row['addon_author'], $addon_row['addon_organisation'], $addon_row['addon_version'], $addon_row['addon_description'], 'imports/mods');
     uninstall_addon($name);
     // Clear some cacheing
     require_code('view_modes');
     require_code('zones2');
     require_code('zones3');
     erase_comcode_page_cache();
     erase_tempcode_cache();
     //persistant_cache_delete('OPTIONS');  Done by set_option
     persistant_cache_empty();
     erase_cached_templates();
     // Show it worked / Refresh
     $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }