/** * Installs the blog * * {@internal Missing Long Description}} * * @since 2.1.0 * * @param string $blog_title Blog title. * @param string $user_name User's username. * @param string $user_email User's email. * @param bool $public Whether blog is public. * @param null $deprecated Optional. Not used. * @param string $user_password Optional. User's chosen password. Will default to a random password. * @return array Array keys 'url', 'user_id', 'password', 'password_message'. */ function nxt_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '') { global $nxt_rewrite; if (!empty($deprecated)) { _deprecated_argument(__FUNCTION__, '2.6'); } nxt_check_mysql_version(); nxt_cache_flush(); make_db_current_silent(); populate_options(); populate_roles(); update_option('blogname', $blog_title); update_option('admin_email', $user_email); update_option('blog_public', $public); $guessurl = nxt_guess_url(); update_option('siteurl', $guessurl); // If not a public blog, don't ping. if (!$public) { update_option('default_pingback_flag', 0); } // Create default user. If the user already exists, the user tables are // being shared among blogs. Just set the role in that case. $user_id = username_exists($user_name); $user_password = trim($user_password); $email_password = false; if (!$user_id && empty($user_password)) { $user_password = nxt_generate_password(12, false); $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); $user_id = nxt_create_user($user_name, $user_password, $user_email); update_user_option($user_id, 'default_password_nag', true, true); $email_password = true; } else { if (!$user_id) { // Password has been provided $message = '<em>' . __('Your chosen password.') . '</em>'; $user_id = nxt_create_user($user_name, $user_password, $user_email); } else { $message = __('User already exists. Password inherited.'); } } $user = new nxt_User($user_id); $user->set_role('administrator'); nxt_install_defaults($user_id); $nxt_rewrite->flush_rules(); nxt_new_blog_notification($blog_title, $guessurl, $user_id, $email_password ? $user_password : __('The password you chose during the install.')); nxt_cache_flush(); return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message); }
/** * Assign default styles to $styles object. * * Nothing is returned, because the $styles parameter is passed by reference. * Meaning that whatever object is passed will be updated without having to * reassign the variable that was passed back to the same value. This saves * memory. * * Adding default styles is not the only task, it also assigns the base_url * property, the default version, and text direction for the object. * * @since 2.6.0 * * @param object $styles */ function nxt_default_styles(&$styles) { // This checks to see if site_url() returns something and if it does not // then it assigns $guess_url to nxt_guess_url(). Strange format, but it works. if (!($guessurl = site_url())) { $guessurl = nxt_guess_url(); } $styles->base_url = $guessurl; $styles->content_url = defined('nxt_CONTENT_URL') ? nxt_CONTENT_URL : ''; $styles->default_version = get_bloginfo('version'); $styles->text_direction = function_exists('is_rtl') && is_rtl() ? 'rtl' : 'ltr'; $styles->default_dirs = array('/nxt-admin/', '/nxt-includes/css/'); $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : ''; $rtl_styles = array('nxt-admin', 'ie', 'media', 'admin-bar', 'nxtlink'); // Any rtl stylesheets that don't have a .dev version for ltr $no_suffix = array('farbtastic'); $styles->add('nxt-admin', "/nxt-admin/css/nxt-admin{$suffix}.css", array(), '20111208'); $styles->add('ie', "/nxt-admin/css/ie{$suffix}.css", array(), '20111130'); $styles->add_data('ie', 'conditional', 'lte IE 7'); // all colors stylesheets need to have the same query strings (cache manifest compat) $colors_version = '20111206'; // Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string. $styles->add('colors', true, array('nxt-admin'), $colors_version); // do not refer to these directly, the right one is queued by the above "meta" colors handle $styles->add('colors-fresh', "/nxt-admin/css/colors-fresh{$suffix}.css", array('nxt-admin'), $colors_version); $styles->add('colors-classic', "/nxt-admin/css/colors-classic{$suffix}.css", array('nxt-admin'), $colors_version); $styles->add('media', "/nxt-admin/css/media{$suffix}.css", array(), '20111119'); $styles->add('install', "/nxt-admin/css/install{$suffix}.css", array(), '20111117'); // Readme as well $styles->add('thickbox', '/nxt-includes/js/thickbox/thickbox.css', array(), '20111117'); $styles->add('farbtastic', '/nxt-admin/css/farbtastic.css', array(), '1.3u1'); $styles->add('jcrop', '/nxt-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8'); $styles->add('imgareaselect', '/nxt-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1'); $styles->add('admin-bar', "/nxt-includes/css/admin-bar{$suffix}.css", array(), '20111209'); $styles->add('nxt-jquery-ui-dialog', "/nxt-includes/css/jquery-ui-dialog{$suffix}.css", array(), '20111107'); $styles->add('editor-buttons', "/nxt-includes/css/editor-buttons{$suffix}.css", array(), '20111114'); $styles->add('nxt-pointer', "/nxt-includes/css/nxt-pointer{$suffix}.css", array(), '20111205'); foreach ($rtl_styles as $rtl_style) { $styles->add_data($rtl_style, 'rtl', true); if ($suffix && !in_array($rtl_style, $no_suffix)) { $styles->add_data($rtl_style, 'suffix', $suffix); } } }
/** * Redirects a user to login for BP pages that require access control and adds an error message (if * one is provided). * If authenticated, redirects user back to requested content by default. * * @package BuddyPress Core * @since 1.5 */ function bp_core_no_access($args = '') { global $bp; $defaults = array('mode' => '1', 'message' => __('You must log in to access the page you requested.', 'buddypress'), 'redirect' => nxt_guess_url(), 'root' => $bp->root_domain); $r = nxt_parse_args($args, $defaults); extract($r, EXTR_SKIP); // Apply filters to these variables $mode = apply_filters('bp_no_access_mode', $mode, $root, $redirect, $message); $redirect = apply_filters('bp_no_access_redirect', $redirect, $root, $message, $mode); $root = trailingslashit(apply_filters('bp_no_access_root', $root, $redirect, $message, $mode)); $message = apply_filters('bp_no_access_message', $message, $root, $redirect, $mode); switch ($mode) { // Option to redirect to nxt-login.php // Error message is displayed with bp_core_no_access_nxt_login_error() case 2: if ($redirect) { bp_core_redirect(nxt_login_url($redirect) . '&action=bpnoaccess'); } else { bp_core_redirect($root); } break; // Redirect to root with "redirect_to" parameter // Error message is displayed with bp_core_add_message() // Redirect to root with "redirect_to" parameter // Error message is displayed with bp_core_add_message() case 1: default: if ($redirect) { $url = add_query_arg('redirect_to', urlencode($redirect), $root); } else { $url = $root; } if ($message) { bp_core_add_message($message, 'error'); } bp_core_redirect($url); break; } }
/** * Redirects to the installer if NXTClass is not installed. * * Dies with an error message when multisite is enabled. * * @access private * @since 3.0.0 */ function nxt_not_installed() { if (is_multisite()) { if (!is_blog_installed() && !defined('nxt_INSTALLING')) { nxt_die(__('The site you have requested is not installed properly. Please contact the system administrator.')); } } elseif (!is_blog_installed() && false === strpos($_SERVER['PHP_SELF'], 'install.php') && !defined('nxt_INSTALLING')) { $link = nxt_guess_url() . '/nxt-admin/install.php'; require ABSPATH . nxtINC . '/kses.php'; require ABSPATH . nxtINC . '/pluggable.php'; require ABSPATH . nxtINC . '/formatting.php'; nxt_redirect($link); die; } }
/** * Create NXTClass options and set the default values. * * @since 1.5.0 * @uses $nxtdb * @uses $nxt_db_version */ function populate_options() { global $nxtdb, $nxt_db_version, $current_site, $nxt_current_db_version; $guessurl = nxt_guess_url(); do_action('populate_options'); if (ini_get('safe_mode')) { // Safe mode can break mkdir() so use a flat structure by default. $uploads_use_yearmonth_folders = 0; } else { $uploads_use_yearmonth_folders = 1; } $template = nxt_DEFAULT_THEME; // If default theme is a child theme, we need to get its template foreach ((array) get_themes() as $theme) { if (nxt_DEFAULT_THEME == $theme['Stylesheet']) { $template = $theme['Template']; break; } } $options = array('siteurl' => $guessurl, 'blogname' => __('My Site'), 'blogdescription' => __('Another NXTClass site'), 'users_can_register' => 1, 'admin_email' => '*****@*****.**', 'start_of_week' => 1, 'use_balanceTags' => 0, 'use_smilies' => 1, 'require_name_email' => 1, 'comments_notify' => 1, 'mailserver_url' => 'mail.example.com', 'mailserver_login' => '*****@*****.**', 'mailserver_pass' => 'password', 'mailserver_port' => 110, 'default_category' => 1, 'default_comment_status' => 'open', 'default_ping_status' => 'open', 'default_pingback_flag' => 1, 'default_post_edit_rows' => 20, 'posts_per_page' => 10, 'date_format' => __('F j, Y'), 'time_format' => __('g:i a'), 'links_updated_date_format' => __('F j, Y g:i a'), 'links_recently_updated_prepend' => '<em>', 'links_recently_updated_append' => '</em>', 'links_recently_updated_time' => 120, 'comment_moderation' => 0, 'moderation_notify' => 1, 'permalink_structure' => '', 'gzipcompression' => 0, 'hack_file' => 0, 'blog_charset' => 'UTF-8', 'moderation_keys' => '', 'active_plugins' => array('achievements/loader.php', 'bp-template-pack/loader.php', 'buddypress-user-account-type-lite/buddypress-user-account-type.php', 'buddypress/bp-loader.php', 'members/members.php', 'nxtclass-bootstrap-css/hlt-bootstrapcss.php', 'nxtclass-wiki/nxtclass-wiki.php', 'nxt-fb-autoconnect/Main.php'), 'home' => $guessurl, 'category_base' => '', 'advanced_edit' => 0, 'comment_max_links' => 2, 'gmt_offset' => date('Z') / 3600, 'default_email_category' => 1, 'recently_edited' => '', 'template' => $template, 'stylesheet' => nxt_DEFAULT_THEME, 'comment_whitelist' => 1, 'blacklist_keys' => '', 'comment_registration' => 0, 'rss_language' => 'en', 'html_type' => 'text/html', 'use_trackback' => 0, 'default_role' => 'contibuter', 'db_version' => $nxt_db_version, 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, 'upload_path' => '', 'blog_public' => '1', 'default_link_category' => 2, 'show_on_front' => 'posts', 'tag_base' => '', 'show_avatars' => '1', 'avatar_rating' => 'G', 'upload_url_path' => '', 'thumbnail_size_w' => 150, 'thumbnail_size_h' => 150, 'thumbnail_crop' => 1, 'medium_size_w' => 300, 'medium_size_h' => 300, 'avatar_default' => 'mystery', 'enable_app' => 0, 'enable_xmlrpc' => 0, 'large_size_w' => 1024, 'large_size_h' => 1024, 'image_default_link_type' => 'file', 'image_default_size' => '', 'image_default_align' => '', 'close_comments_for_old_posts' => 0, 'close_comments_days_old' => 14, 'thread_comments' => 1, 'thread_comments_depth' => 5, 'page_comments' => 0, 'comments_per_page' => 50, 'default_comments_page' => 'newest', 'comment_order' => 'asc', 'sticky_posts' => array(), 'widget_categories' => array(), 'widget_text' => array(), 'widget_rss' => array(), 'timezone_string' => '', 'embed_autourls' => 1, 'embed_size_w' => '', 'embed_size_h' => 600, 'page_for_posts' => 0, 'page_on_front' => 0, 'default_post_format' => 0); // 3.3 if (!is_multisite()) { $options['initial_db_version'] = !empty($nxt_current_db_version) && $nxt_current_db_version < $nxt_db_version ? $nxt_current_db_version : $nxt_db_version; } // 3.0 multisite if (is_multisite()) { /* translators: blog tagline */ $options['blogdescription'] = sprintf(__('Just another %s site'), $current_site->site_name); $options['permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/'; } // Set autoload to no for these options $fat_options = array('moderation_keys', 'recently_edited', 'blacklist_keys'); $existing_options = $nxtdb->get_col("SELECT option_name FROM {$nxtdb->options}"); $insert = ''; foreach ($options as $option => $value) { if (in_array($option, $existing_options)) { continue; } if (in_array($option, $fat_options)) { $autoload = 'no'; } else { $autoload = 'yes'; } $option = $nxtdb->escape($option); if (is_array($value)) { $value = serialize($value); } $value = $nxtdb->escape($value); if (!empty($insert)) { $insert .= ', '; } $insert .= "('{$option}', '{$value}', '{$autoload}')"; } if (!empty($insert)) { $nxtdb->query("INSERT INTO {$nxtdb->options} (option_name, option_value, autoload) VALUES " . $insert); } // in case it is set, but blank, update "home" if (!__get_option('home')) { update_option('home', $guessurl); } // Delete unused options $unusedoptions = array('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_nxtnonce', '_nxt_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'nxtorg_popular_tags', 'what_to_show'); foreach ($unusedoptions as $option) { delete_option($option); } // delete obsolete magpie stuff $nxtdb->query("DELETE FROM {$nxtdb->options} WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?\$'"); }