Esempio n. 1
0
function sp_setup_globals()
{
    global $spGlobals, $current_user, $spBootCache, $spMeta, $spDevice;
    if ($spBootCache['globals'] == true) {
        return;
    }
    # Main admin options
    $spGlobals['admin'] = sp_get_option('sfadminsettings');
    $spGlobals['lockdown'] = sp_get_option('sflockdown');
    $spGlobals['editor'] = 0;
    # Display array
    $spGlobals['display'] = sp_get_option('sfdisplay');
    # Current theme data
    $spGlobals['theme'] = sp_get_current_sp_theme();
    # if mobile device then force integrated editor toolbar to on
    if ($spDevice == 'mobile' || $spDevice == 'tablet') {
        $spGlobals['display']['editor']['toolbar'] = true;
        if ($spDevice == 'mobile') {
            $spGlobals['mobile-display'] = sp_get_option('sp_mobile_theme');
        } else {
            $spGlobals['mobile-display'] = sp_get_option('sp_tablet_theme');
        }
    }
    # Load up sfmeta
    $spMeta = spdb_table(SFMETA, 'autoload=1');
    if (!empty($spMeta)) {
        foreach ($spMeta as $s) {
            if (!empty($s)) {
                $spGlobals[$s->meta_type][$s->meta_key] = maybe_unserialize($s->meta_value);
            }
        }
    }
    # create topic/post cache if found to be missing!
    if (!isset($spGlobals['topic_cache']['new']) || empty($spGlobals['topic_cache']['new'])) {
        $spGlobals['topic_cache']['new'] = sp_rebuild_topic_cache();
    }
    # Pre-define a few others
    $spGlobals['canonicalurl'] = false;
    # set up array of disabled forums
    $spGlobals['disabled_forums'] = spdb_select('col', 'SELECT forum_id FROM ' . SFFORUMS . ' WHERE forum_disabled=1', ARRAY_A);
    $spBootCache['globals'] = true;
}
<?php

/*
Simple:Press
Ahah call for acknowledgements
$LastChangedDate: 2014-06-14 17:34:16 -0700 (Sat, 14 Jun 2014) $
$Rev: 11559 $
*/
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
    die('Access denied - you cannot directly call this file');
}
sp_forum_api_support();
$theme = sp_get_current_sp_theme();
$out = '';
$out .= '<div id="spAbout">';
$out .= '<img src="' . SFCOMMONIMAGES . 'sp-small-logo.png" alt="" title="" /><br />';
$out .= '<p>&copy; 2006-' . date('Y') . ' ' . sp_text('by') . ' <a href="http://www.yellowswordfish.com"><b>Andy Staines</b></a> ' . sp_text('and') . ' <a href="http://cruisetalk.org/"><b>Steve Klasen</b></a></p>';
$out .= '<p><a href="http://twitter.com/simpleforum">' . sp_text('Follow us On Twitter') . '</a></p>';
$out .= '<hr />';
$out .= '<p>';
$ack = array(sp_text('printThis by Jason Day') . ': <a href="https://github.com/jasonday/printThis">printThis</a>', sp_text('Math Spam Protection based on code by Michael Woehrer') . ': <a href="http://sw-guide.de/">Software Guide</a>', sp_text('Calendar Date Picker by TengYong Ng') . ': <a href="http://www.rainforestnet.com">Rain Forest Net</a>', sp_text('Image Uploader by Andrew Valums') . ': <a href="http://valums.com/ajax-upload/">Ajax upload</a>', sp_text('Checkbox and Radio Button transformations by') . ': <a href="http://www.no-margin-for-errors.com/">Stephane Caron</a>', sp_text('SPF RPX implementation uses code and ideas from RPX') . ': <a href="http://rpxwiki.com/WordpressPlugin">Brian Ellin</a>', sp_text('Popup Tooltips by the Vertigo Project') . ': <a href="http://www.vertigo-project.com/">Vertigo Project</a>', sp_text('Table Drag and Drop') . ': <a href="http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/">Isocra Consulting</a>', sp_text('Mobile Device Detection based on code by Brett Jankord') . ': <a href="http://www.brettjankord.com/2012/01/16/categorizr-a-modern-device-detection-script/">Categorizr</a>', sp_text('CSS and JS Concatenation based on code by Ronen Yacobi') . ': <a href="http://http://yacobi.info/">CSS And Script File Aggregation</a>');
$ack = apply_filters('sph_acknowledgements', $ack);
foreach ($ack as $a) {
    $out .= $a . '<br />';
}
$out .= '</p>';
$out .= '<hr />';
$out .= '<p>' . sp_text('Our thanks to all the people who have aided, abetted, coded, suggested and helped test this plugin') . '</p><br />';
$out .= sp_text('This forum is using the') . ' <strong>' . $theme['theme'] . '</strong> ' . sp_text('theme') . '<br />';
if (!empty($theme['parent'])) {
    $out .= sp_text('a child theme of the') . ' <strong>' . $theme['parent'] . '</strong> ' . sp_text('theme') . '<br />';
function sp_load_template($tempName)
{
    # set up some globals for theme template files to use directly
    global $spGroupView, $spThisGroup, $spForumView, $spThisForum, $spThisSubForum, $spThisForumSubs, $spTopicView, $spThisTopic, $spThisPost, $spThisPostUser, $spListView, $spThisListTopic, $spThisUser, $spProfileUser, $spMembersList, $spThisMemberGroup, $spThisMember, $spGlobals, $spVars, $spDevice, $spMobile;
    # some beginning hooks
    $tempName = apply_filters('sph_template_load_name', $tempName);
    do_action('sph_template_load_begin', $tempName);
    do_action('sph_template_load_begin_' . $tempName);
    # find the template
    $curTheme = sp_get_current_sp_theme();
    if (!empty($tempName) && file_exists($tempName)) {
        include $tempName;
    } else {
        if (!empty($tempName) && file_exists(SPTEMPLATES . $tempName)) {
            include SPTEMPLATES . $tempName;
        } else {
            if (!empty($tempName) && !empty($curTheme['parent']) && file_exists(SPTHEMEBASEDIR . $curTheme['parent'] . '/templates/' . $tempName)) {
                include SPTHEMEBASEDIR . $curTheme['parent'] . '/templates/' . $tempName;
            } else {
                $tempName = explode('/', $tempName);
                echo '<p class="spCenter spHeaderName">[' . $tempName[count($tempName) - 1] . '] - ' . sp_text('Template File Not Found') . '</p>';
                echo '<div class="spHeaderMessage">';
                echo '<p>' . spa_text('Sorry, but the required template file could not be found or could not be opened.') . '</p>';
                echo '<br/><p>';
                spa_etext('This can be caused by a missing/corrupt theme or theme file. Please check the Simple:Press Theme List admin panel and make sure a valid theme is selected. Or please check the location of the selected theme on your server and make sure the theme and the required template file exist.');
                echo '</p>';
                echo '</div>';
            }
        }
    }
    # some ending hooks
    do_action('sph_template_load_end', $tempName);
    do_action('sph_template_load_end_' . $tempName);
}
function sp_find_template($path, $file)
{
    # bail if we dont have a file to search for
    if (empty($file)) {
        return '';
    }
    # find template file checking theme, parent and finally path
    $curTheme = sp_get_current_sp_theme();
    if (file_exists(SPTEMPLATES . $file)) {
        return SPTEMPLATES . $file;
    } else {
        if (!empty($curTheme['parent']) && file_exists(SPTHEMEBASEDIR . $curTheme['parent'] . '/templates/' . $file)) {
            return SPTHEMEBASEDIR . $curTheme['parent'] . '/templates/' . $file;
        } else {
            return $path . $file;
        }
    }
}
function sp_load_plugin_styles()
{
    $curTheme = sp_get_current_sp_theme();
    # get optional color variant to pass to stylesheet
    $curTheme = apply_filters('sph_theme', $curTheme);
    # handle chiild themes
    $parentTheme = !empty($curTheme['parent']) ? sp_get_theme_data(SPTHEMEBASEDIR . $curTheme['parent'] . '/spTheme.txt') : '';
    # handle color overlays
    $vars = !empty($curTheme['color']) ? '?color=' . esc_attr($curTheme['color']) : '';
    # handle RTL
    if (is_rtl()) {
        $vars = !empty($vars) ? "{$vars}&amp;rtl=1" : '?rtl=1';
    }
    $reset = is_rtl() ? 'reset.rtl.css' : 'reset,css';
    # enqueue the main theme css
    if (sp_is_plugin_active('user-selection/sp-user-selection-plugin.php')) {
        if (!empty($parentTheme)) {
            $cssTheme = strpos($parentTheme['Stylesheet'], '.css') ? true : false;
            if ($cssTheme && file_exists(SPTHEMEBASEDIR . $curTheme['parent'] . '/styles/' . $reset)) {
                wp_enqueue_style('sp-parent-reset', SPTHEMEBASEURL . $curTheme['parent'] . '/styles/' . $reset);
            }
            wp_enqueue_style('sp-parent', SPTHEMEBASEURL . $curTheme['parent'] . '/styles/' . $parentTheme['Stylesheet'] . $vars);
            if (is_rtl() && $cssTheme && file_exists(SPTHEMEBASEDIR . $curTheme['parent'] . '/styles/rtl.css')) {
                wp_enqueue_style('sp-parent-rtl', SPTHEMEBASEURL . $curTheme['parent'] . '/styles/rtl.css');
            }
        }
        $cssTheme = strpos(SPTHEMECSS, '.css') ? true : false;
        if ($cssTheme && file_exists(SPTHEMEDIR . $reset)) {
            wp_enqueue_style('sp-theme-reset', SPTHEMECSSEXTRA . $reset);
        }
        wp_enqueue_style('sp-theme', SPTHEMECSS . $vars);
        if (is_rtl() && $cssTheme && file_exists(SPTHEMEDIR . 'rtl.css')) {
            wp_enqueue_style('sp-theme-rtl', SPTHEMECSSEXTRA . 'rtl.css');
        }
    } else {
        if (!empty($parentTheme)) {
            $cssTheme = strpos($parentTheme['Stylesheet'], '.css') ? true : false;
            if ($cssTheme && file_exists(SPTHEMEBASEDIR . $curTheme['parent'] . '/styles/' . $reset)) {
                sp_plugin_enqueue_style('sp-parent-reset', SPTHEMEBASEURL . $curTheme['parent'] . '/styles/' . $reset);
            }
            sp_plugin_enqueue_style('sp-parent', SPTHEMEBASEURL . $curTheme['parent'] . '/styles/' . $parentTheme['Stylesheet'] . $vars);
            if (is_rtl() && $cssTheme && file_exists(SPTHEMEBASEDIR . $curTheme['parent'] . '/styles/rtl.css')) {
                sp_plugin_enqueue_style('sp-parent-rtl', SPTHEMEBASEURL . $curTheme['parent'] . '/styles/rtl.css');
            }
        }
        $cssTheme = strpos(SPTHEMECSS, '.css') ? true : false;
        if ($cssTheme && file_exists(SPTHEMEDIR . $reset)) {
            sp_plugin_enqueue_style('sp-theme-reset', SPTHEMECSSEXTRA . $reset);
        }
        sp_plugin_enqueue_style('sp-theme', SPTHEMECSS . $vars);
        if (is_rtl() && $cssTheme && file_exists(SPTHEMEDIR . 'rtl.css')) {
            sp_plugin_enqueue_style('sp-theme-rtl', SPTHEMECSSEXTRA . 'rtl.css');
        }
    }
    # concat (if needed) and enqueue the plugin css
    do_action('sph_print_plugin_styles');
    $combine_css = sp_get_option('combinecss');
    if ($combine_css) {
        sp_combine_plugin_css_files();
    } else {
        global $sp_plugin_styles;
        if (!empty($sp_plugin_styles)) {
            foreach ($sp_plugin_styles->queue as $handle) {
                wp_enqueue_style($handle, $sp_plugin_styles->registered[$handle]->src);
            }
        }
    }
    do_action('sph_styles_end');
}