Example #1
0
function TPcheckAdminAreas()
{
    global $context;
    TPcollectPermissions();
    foreach ($context['TPortal']['adminlist'] as $adm => $val) {
        if (allowedTo($adm)) {
            return true;
        }
    }
    return false;
}
Example #2
0
function TPortal_init()
{
    global $context, $txt, $user_info, $settings, $boarddir, $sourcedir, $modSettings;
    // has init been run before? if so return!
    if (isset($context['TPortal']['fixed_width'])) {
        return;
    }
    if (loadLanguage('TPortal') == false) {
        loadLanguage('TPortal', 'english');
    }
    $context['TPortal'] = array();
    $context['TPortal']['querystring'] = $_SERVER['QUERY_STRING'];
    if (!isset($context['forum_name'])) {
        $context['forum_name'] = '';
    }
    // Include a ton of functions.
    require_once $sourcedir . '/TPSubs.php';
    // Add all the TP settings into ['TPortal']
    setupTPsettings();
    // go back on showing attachments..
    if (isset($_GET['action']) && $_GET['action'] == 'dlattach') {
        return;
    }
    // Grab the SSI for its functionality
    require_once $boarddir . '/SSI.php';
    // Load JQuery if it's not set (anticipated for SMF2.1)
    if (!isset($modSettings['jquery_source'])) {
        $context['html_headers'] .= '
			<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>';
    }
    fetchTPhooks();
    doModules();
    // set up the layers, but not for certain actions
    if (!isset($_REQUEST['preview']) && !isset($_REQUEST['quote']) && !isset($_REQUEST['xml']) && !isset($aoptions['nolayer'])) {
        $context['template_layers'][] = $context['TPortal']['hooks']['tp_layer'];
    }
    loadtemplate('TPsubs');
    loadtemplate('TPBlockLayout');
    // is the permanent theme option set?
    if (isset($_GET['permanent']) && !empty($_GET['theme']) && $context['user']['is_logged']) {
        TP_permaTheme($_GET['theme']);
    }
    // do after action
    if (isset($_GET['page'])) {
        $context['shortID'] = doTPpage();
    } elseif (isset($_GET['cat'])) {
        $context['catshortID'] = doTPcat();
    } else {
        if (!isset($_GET['action']) && !isset($_GET['board']) && !isset($_GET['topic'])) {
            doTPfrontpage();
        }
    }
    // determine the blocks
    doTPblocks();
    // determine which sidebars to hide
    TP_whichHideBars();
    // Load the stylesheet stuff
    TP_loadCSS();
    // if we are in permissions admin section, load all permissions
    if (isset($_GET['action']) && $_GET['action'] == 'permissions' || isset($_GET['area']) && $_GET['area'] == 'permissions') {
        TPcollectPermissions();
    }
    // Show search/frontpage topic layers?
    TP_doTagSearchLayers();
    // any modules needed to load then?
    if (!empty($context['TPortal']['always_loaded']) && sizeof($context['TPortal']['always_loaded']) > 0) {
        foreach ($context['TPortal']['always_loaded'] as $loaded => $fil) {
            require_once $boarddir . '/tp-files/tp-modules/' . $fil;
        }
    }
    // set cookie change for selected upshrinks
    tp_setupUpshrinks();
    // finally..any errors finding an article or category?
    if (!empty($context['art_error'])) {
        fatal_error($txt['tp-articlenotexist'], false);
    }
    if (!empty($context['cat_error'])) {
        fatal_error($txt['tp-categorynotexist'], false);
    }
    // let a module take over
    if ($context['TPortal']['front_type'] == 'module' && !isset($_GET['page']) && !isset($_GET['cat']) && !isset($_GET['action'])) {
        // let the module take over
        require_once $context['TPortal']['tpmodules']['frontsection'][$context['TPortal']['front_module']]['sourcefile'];
        if (function_exists($context['TPortal']['tpmodules']['frontsection'][$context['TPortal']['front_module']]['function'])) {
            call_user_func($context['TPortal']['tpmodules']['frontsection'][$context['TPortal']['front_module']]['function']);
        } else {
            echo $txt['tp-nomodule'];
        }
    }
}