/** * 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 © ' . $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')); }
/** * UI for a logo wizard step (set). * * @return tempcode The UI */ function __make_logo() { $title = get_page_title('_LOGOWIZARD', true, array(integer_format(3), integer_format(3))); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/logowizard'; $theme = post_param('theme'); // Do it require_code('themes2'); $rand = uniqid('', true); foreach (array($theme, 'default') as $logo_save_theme) { $path = 'themes/' . $logo_save_theme . '/images_custom/' . $rand . '.png'; $img = generate_logo(post_param('name'), post_param('title'), false, $logo_save_theme, 'logo-template'); @imagepng($img, get_custom_file_base() . '/' . $path) or intelligent_write_error($path); imagedestroy($img); actual_edit_theme_image('logo/-logo', $logo_save_theme, user_lang(), 'logo/-logo', $path); if (addon_installed('collaboration_zone')) { actual_edit_theme_image('logo/collaboration-logo', $logo_save_theme, user_lang(), 'logo/collaboration-logo', $path); } $rand = uniqid('', true); $path = 'themes/' . $logo_save_theme . '/images_custom/' . $rand . '.png'; $img = generate_logo(post_param('name'), post_param('title'), false, NULL, 'trimmed-logo-template'); @imagepng($img, get_custom_file_base() . '/' . $path) or intelligent_write_error($path); imagedestroy($img); actual_edit_theme_image('logo/trimmed-logo', $logo_save_theme, user_lang(), 'logo/trimmed-logo', $path); } persistant_cache_delete('THEME_IMAGES'); breadcrumb_set_parents(array(array('_SELF:_SELF:make_logo', do_lang_tempcode('START')))); $message = do_lang_tempcode('LOGOWIZARD_3_DESCRIBE', escape_html($theme)); return inform_screen($title, $message); }
$b = 0; } $FILE_BASE = substr($FILE_BASE, 0, $a > $b ? $a : $b); } if (!is_file($FILE_BASE . '/sources/global.php')) { $a = strrpos($FILE_BASE, '/'); if ($a === false) { $a = 0; } $b = strrpos($FILE_BASE, '\\'); if ($b === false) { $b = 0; } $RELATIVE_PATH = substr($FILE_BASE, ($a > $b ? $a : $b) + 1); $FILE_BASE = substr($FILE_BASE, 0, $a > $b ? $a : $b); } else { $RELATIVE_PATH = ''; } @chdir($FILE_BASE); global $NON_PAGE_SCRIPT; $NON_PAGE_SCRIPT = 1; global $FORCE_INVISIBLE_GUEST; $FORCE_INVISIBLE_GUEST = 0; if (!is_file($FILE_BASE . '/sources/global.php')) { exit('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . chr(10) . '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"><head><title>Critical startup error</title></head><body><h1>ocPortal startup error</h1><p>The second most basic ocPortal startup file, sources/global.php, could not be located. This is almost always due to an incomplete upload of the ocPortal system, so please check all files are uploaded correctly.</p><p>Once all ocPortal files are in place, ocPortal must actually be installed by running the installer. You must be seeing this message either because your system has become corrupt since installation, or because you have uploaded some but not all files from our manual installer package: the quick installer is easier, so you might consider using that instead.</p><p>ocProducts maintains full documentation for all procedures and tools, especially those for installation. These may be found on the <a href="http://ocportal.com">ocPortal website</a>. If you are unable to easily solve this problem, we may be contacted from our website and can help resolve it for you.</p><hr /><p style="font-size: 0.8em">ocPortal is a website engine created by ocProducts.</p></body></html>'); } require $FILE_BASE . '/sources/global.php'; require_code('themewizard'); require_code('themes2'); generate_logo(get_param('name'), get_param('title'), true, get_param('theme'));