/**
     * ShowContent
     * Output the content.
     */
    function pmxc_ShowContent()
    {
        global $context, $scripturl, $txt;
        // User logged in?
        if ($context['user']['is_logged']) {
            // avatar
            if (!empty($context['user']['avatar']) && !empty($this->cfg['config']['settings']['show_avatar'])) {
                $avasize = getimagesize($context['user']['avatar']['href']);
                $fact = $avasize[0] > $avasize[1] ? 50 / $avasize[0] : 50 / $avasize[1];
                $leftpad = strval(intval($avasize[0] * $fact + 8));
                echo '
									<div style="padding-left:' . $leftpad . 'px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"' . (isset($this->cfg['config']['visuals']['hellotext']) ? ' class="' . $this->cfg['config']['visuals']['hellotext'] . '"' : '') . '>' . $txt['pmx_hello'] . '<br /><a href="' . $scripturl . '?action=profile;u=' . $context['user']['id'] . '" title="' . $context['user']['name'] . '"><b>' . $context['user']['name'] . '</b></a>
									</div>';
                // avatar
                if (!empty($context['user']['avatar']) && !empty($this->cfg['config']['settings']['show_avatar'])) {
                    echo '
									<div style="float:left;margin-top:-38px;">
										<a style="float-left;margin-top:-20px;" class="pmx_avatar" href="' . $scripturl . '?action=profile;u=' . $context['user']['id'] . '" title="' . $context['user']['name'] . '">' . $context['user']['avatar']['image'] . '</a>
									</div>';
                }
            } else {
                echo '
									<div' . (isset($this->cfg['config']['visuals']['hellotext']) ? 'block;" class="' . $this->cfg['config']['visuals']['hellotext'] . '"' : '') . '>' . $txt['pmx_hello'] . '<a href="' . $scripturl . '?action=profile;u=' . $context['user']['id'] . '"><b>' . $context['user']['name'] . '</b></a>
									</div>';
            }
            $img = '<img src="' . $context['pmx_syscssurl'] . 'Images/bullet_blue.gif" alt="*" title="" />';
            $img1 = '<img src="' . $context['pmx_syscssurl'] . 'Images/bullet_red.gif" alt="*" title="" />';
            if (!empty($context['user']['avatar']) && !empty($this->cfg['config']['settings']['show_avatar'])) {
                echo '
									<ul style="margin-top:20px;" class="userlogin">';
            } else {
                echo '
									<ul class="userlogin smalltext">';
            }
            // show pm?
            if (!empty($this->cfg['config']['settings']['show_pm']) && $context['allow_pm']) {
                echo '
										<li>' . ($context['user']['unread_messages'] > 0 ? $img1 : $img) . '<span><a href="' . $scripturl . '?action=pm">' . $txt['pmx_pm'] . ($context['user']['unread_messages'] > 0 ? ': ' . $context['user']['unread_messages'] . ' <img src="' . $context['pmx_imageurl'] . 'newpm.gig" alt="*" title="' . $context['user']['unread_messages'] . '" />' : '') . '</a></span></li>';
            }
            // Are there any members waiting for approval?
            if (!empty($this->cfg['config']['settings']['show_unapprove']) && !empty($context['unapproved_members'])) {
                echo '
										<li>' . $img1 . '<span><a href="' . $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve">' . $txt['pmx_unapproved_members'] . ' <b>' . $context['unapproved_members'] . '</b></a></span></li>';
            }
            // show post?
            if (!empty($this->cfg['config']['settings']['show_posts'])) {
                echo '
										<li>' . $img . '<span><a href="' . $scripturl . '?action=unread">' . $txt['pmx_unread'] . '</a></span></li>
										<li>' . $img . '<span><a href="' . $scripturl . '?action=unreadreplies">' . $txt['pmx_replies'] . '</a></span></li>
										<li>' . $img . '<span><a href="' . $scripturl . '?action=profile;area=showposts;u=' . $context['user']['id'] . '">' . $txt['pmx_showownposts'] . '</a></span></li>';
            }
            echo '
									</ul>';
            // Is the forum in maintenance mode?
            if ($context['in_maintenance'] && $context['user']['is_admin']) {
                echo '
									<b>' . $txt['pmx_maintenace'] . '</b><br />';
            }
            // Show the total time logged in?
            if (!empty($context['user']['total_time_logged_in']) && isset($this->cfg['config']['settings']['show_logtime']) && $this->cfg['config']['settings']['show_logtime'] == 1) {
                $totm = $context['user']['total_time_logged_in'];
                $form = '%s: %s%s %s%s %s%s';
                echo sprintf($form, $txt['pmx_loggedintime'], $totm['days'], $txt['pmx_Ldays'], $totm['hours'], $txt['pmx_Lhours'], $totm['minutes'], $txt['pmx_Lminutes']);
                echo '<br />';
            }
        } else {
            if (!empty($this->cfg['config']['settings']['show_login']) && pmx_checkECL_Cookie(true)) {
                echo '
									<div style="padding-top:4px;">
										<form action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="', $context['character_set'], '">
											<input id=username" type="text" name="user" size="10" class="input_text" style="width:48%;float:left;margin-bottom:3px;" value="' . $txt['pmxdummyuser'] . '" onclick="usercheck(this)" />
											<input type="password" name="passwrd" size="10" class="input_password" value="" style="width:48%;float:right;margin-bottom:3px;margin-right:4px;" />
											<select name="cookielength">
												<option value="60">', $txt['one_hour'], '</option>
												<option value="1440">', $txt['one_day'], '</option>
												<option value="10080">', $txt['one_week'], '</option>
												<option value="43200">', $txt['one_month'], '</option>
												<option value="-1" selected="selected">', $txt['forever'], '</option>
											</select>
											<input type="hidden" name="hash_passwrd" value="" />
											<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
											<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />
											<input style="float:right;margin-right:4px;" type="submit" value="' . $txt['login'] . '" />
										</form>
										<script type="text/javascript">function usercheck(elm){if(elm.value=="' . $txt['pmxdummyuser'] . '"){elm.value = "";}}</script>
									' . $txt['login_dec'] . '
									</div>';
            }
        }
        // show current time?
        if (!empty($this->cfg['config']['settings']['show_time'])) {
            if (!empty($this->cfg['config']['settings']['show_realtime'])) {
                $cdate = date('Y,n-1,j,G,', Forum_Time()) . intval(date('i', Forum_Time())) . ',' . intval(date('s', Forum_Time()));
                echo '
								<span id="ulClock' . $this->cfg['id'] . '"></span>
								<script type="text/javascript">
								ulClock("' . $this->cfg['id'] . '");
								</script>';
            } else {
                echo $context['current_time'];
            }
        }
        // show logout button?
        if ($context['user']['is_logged'] && !empty($this->cfg['config']['settings']['show_logout'])) {
            echo '
								<br />
								<div style="text-align:center;margin-top:5px;">
									<input class="button_submit" type="button" value="' . $txt['logout'] . '" onclick="DoLogout()" />
								</div>
								<script type="text/javascript">
									function DoLogout()
									{
										window.location = "' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '";
									}
								</script>';
        }
        // show a language dropdown selector
        if (!empty($this->cfg['config']['settings']['show_langsel']) && count($context['pmx']['languages']) > 1) {
            echo '
								<script type="text/javascript">
									if(document.getElementById("languages_form"))
									{
										document.getElementById("languages_form").style.display = "none";
										if(document.getElementsByName("search2"))
											document.getElementsByName("search2")[0].style.marginRight = "0";
									}
								</script>';
            if (isset($_GET['language'])) {
                unset($_GET['language']);
            }
            echo '
								<form id="pmxlangchg' . $this->cfg['id'] . '" accept-charset="' . $context['character_set'] . '" method="post">
									' . (pmx_checkECL_Cookie(true) ? '<input type="hidden" name="redir" value="' . pmx_http_build_query($_GET) . '" />' : '') . '
									<input type="hidden" id="pmxlangval' . $this->cfg['id'] . '" name="language" value="" />
								</form>
								<hr class="pmx_hr" />' . $txt['pmx_langsel'] . '
								<div style="padding-top:3px;">
									<select size="1" style="width:100%;" onchange="pmxSetlang(this, \'' . $this->cfg['id'] . '\')">';
            foreach ($context['pmx']['languages'] as $lang => $sel) {
                echo '
										<option value="' . $lang . '"' . (!empty($sel) ? ' selected="selected"' : '') . '>' . ucfirst($lang) . '</option>';
            }
            echo '
									</select>
								</div>';
        }
    }
/**
* Init all variables and load the settings from the database.
* Check the requests and prepare the templates to load.
*/
function PortaMx($doinit = false)
{
    global $context, $modSettings, $boardurl, $scripturl, $user_info, $maintenance, $language, $pmxCacheFunc, $sc, $cookiename, $txt;
    // we can exit on this...
    if (defined('PortaMx') || isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && empty($doinit)) {
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && !empty($user_info['possibly_robot'])) {
            redirectexit();
        } else {
            return;
        }
    }
    define('PortaMx', 1);
    // no sign up for robots please !!
    if (!empty($user_info['possibly_robot']) && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'signup') {
        redirectexit();
    }
    if (empty($user_info['possibly_robot'])) {
        // portal enable/disable request ?
        if ((isset($_REQUEST['pmxportal']) || isset($_REQUEST['pmxsef'])) && allowedTo('admin_forum')) {
            $mode = 'pmx' . (isset($_REQUEST['pmxportal']) ? 'portal' : 'sef');
            updateSettings(array($mode . '_disabled' => $_REQUEST[$mode] == 'off' ? '1' : '0'));
            redirectexit();
        }
        // clear PortaMx cache request ?
        if (isset($_GET['action']) && isset($_GET['area']) && (in_array($_GET['action'], array('admin', 'portamx')) && $_GET['area'] == 'pmx_cache')) {
            if (isset($_GET[$_SESSION['session_var']]) && $_GET[$_SESSION['session_var']] == $sc) {
                $pmxCacheFunc['clean']();
                $_SESSION['pmx_cache_cleared'] = true;
            }
            if (isset($_SESSION['pmx_last_request'])) {
                redirectexit($_SESSION['pmx_last_request']);
            }
        } elseif (pmx_checkECL_Cookie() && strpos($_SERVER['REQUEST_URL'], 'viewsmfile') === false) {
            $_SESSION['pmx_last_request'] = $_SERVER['REQUEST_URL'];
        }
        $lang = $pmxCacheFunc['get']($user_info['ip'] . '-lang');
        if (!pmx_checkECL_Cookie()) {
            if ($lang === null) {
                // get browser language
                $browserlang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']) : '';
                if (preg_match_all('~en\\b|de\\b~i', $browserlang, $temp) > 0) {
                    $avail = array_keys(PortaMx_getLanguages());
                    if (in_array('de', $temp[0])) {
                        if (in_array('german', $avail)) {
                            $lang = 'german';
                        } elseif (in_array('german-utf8', $avail)) {
                            $lang = 'german-utf8';
                        }
                    } else {
                        $lang = $language;
                    }
                    $_POST['language'] = $lang;
                    $_POST['redir'] = pmx_http_build_query($_GET);
                }
            } else {
                $context['pmx']['currlang'] = $context['user']['language'] = $user_info['language'] = $language = $lang;
            }
            // need to releoad base language
            loadLanguage('index+Modifications');
        } else {
            if ($lang !== null) {
                $_POST['language'] = $lang;
                $_POST['redir'] = pmx_http_build_query($_GET);
            }
        }
        // check if a language change requested
        if (!empty($_POST['language'])) {
            $pmxCacheFunc['clean']();
            $context['pmx']['currlang'] = $context['user']['language'] = $user_info['language'] = $language = $_POST['language'];
            if (pmx_checkECL_Cookie()) {
                // Make it permanent for members.
                if (!empty($user_info['id'])) {
                    updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
                } else {
                    $_SESSION['language'] = $user_info['language'];
                }
            } else {
                $pmxCacheFunc['put']($user_info['ip'] . '-lang', $language, 360, false);
                $_POST['redir'] = pmx_http_build_query($_GET);
            }
            if (isset($_POST['redir'])) {
                redirectexit($_POST['redir']);
            }
        }
    }
    if (empty($modSettings['pmx_eclmodal']) && !pmx_checkECL_Cookie() && (!empty($_REQUEST['action']) && $_REQUEST['action'] != 'xml' || !empty($_REQUEST['page']) || !empty($_REQUEST['cat']) || !empty($_REQUEST['art']))) {
        if (empty($user_info['possibly_robot']) && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'login') {
            setupMenuContext();
            pmx_ECL_Error($_REQUEST['action']);
        } else {
            redirectexit();
        }
    }
    // redirect on illegal request
    if (!empty($_REQUEST['pmxportal']) || !empty($_REQUEST['pmxsef']) || !empty($_REQUEST['pmxerror']) && !empty($_REQUEST['action'])) {
        redirectexit('pmxerror=unknown');
    }
    // check if a permanent theme change requested
    if (isset($_REQUEST['theme']) && isset($_REQUEST['pmxrd'])) {
        PortaMx_ChangeTheme($_REQUEST['theme'], $_REQUEST['pmxrd']);
    }
    // load all settings
    PortaMx_getSettings();
    // shoutbox POST request?
    if (!empty($_POST['pmx_shout']) && !empty($_POST['shoutbox_id'])) {
        PortaMx_GetShoutbox($_POST['shoutbox_id']);
        if (pmx_checkECL_Cookie()) {
            $_SESSION['pmx_shoutreload'] = true;
        }
        exit;
    }
    // exit on follow actions
    $rqaction = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    if (isset($_REQUEST['xml']) || in_array($rqaction, array('jseditor', 'jsoption', '.xml', 'xmlhttp', 'verificationcode', 'printpage'))) {
        return;
    }
    // login with redirect .. correct SEF url
    if ($rqaction == 'login' && !empty($_SESSION['old_url']) && function_exists('pmxsef_query')) {
        $_SESSION['old_url'] = $scripturl . pmx_http_build_query(pmxsef_query(rawurldecode(ltrim(str_replace($boardurl, '', $_SESSION['old_url']), '/'))));
    }
    // check if a pmxscriptdebug/pmxspidertest requested
    $tmp = isset($_GET['pmxscriptdebug']) ? 'pmxscriptdebug' : (isset($_GET['pmxspidertest']) ? 'pmxspidertest' : '');
    if (!empty($tmp) && in_array($_GET[$tmp], array('on', 'off'))) {
        if (allowPmx('pmx_admin')) {
            if ($tmp == 'pmxscriptdebug') {
                pmx_setcookie($tmp, $_GET[$tmp] == 'on' ? '1' : '');
                unset($_GET[$tmp]);
                redirectexit(pmx_http_build_query($_GET));
            } elseif ($tmp == 'pmxspidertest' && $_GET[$tmp] == 'on' && !empty($modSettings['pmx_ecl'])) {
                $logCook = pmx_getcookie($cookiename);
                pmx_setcookie($tmp, $logCook);
                pmx_setcookie($cookiename, '');
                pmx_setcookie('pmx_eclauth', '');
                pmx_setcookie('PHPSESSID', '');
                unset($logCook);
                redirectexit();
            }
        } elseif ($tmp == 'pmxspidertest' && $_GET[$tmp] == 'off' && pmx_getcookie('pmxspidertest')) {
            $udata = pmx_getcookie($tmp);
            if (isset($udata) && is_array($dtmp = unserialize($udata)) && count($dtmp == 4)) {
                pmx_setECL_Cookie();
                pmx_setcookie($cookiename, $udata, $dtmp[2]);
                unset($dtmp);
                unset($udata);
            }
            pmx_setcookie('pmxspidertest', '');
            redirectexit();
        }
    }
    // load common javascript
    loadJavascriptFile(PortaMx_loadCompressed('PortaMx.js'), array('external' => true));
    addInlineJavascript('
	var pmx_restore_top = ' . intval(!empty($context['pmx']['settings']['restoretop'])) . ';');
    if ($doinit || !empty($modSettings['pmxportal_disabled'])) {
        loadLanguage($context['pmx_templatedir'] . 'PortaMx');
        loadCSSFile(PortaMx_loadCompressed('portamx.css'), array('external' => true));
        return;
    }
    // on Admin or Moderate load admin language, css and javascript
    if (($rqaction == 'admin' || $rqaction == 'portamx') && isset($_REQUEST['area']) && in_array($_REQUEST['area'], explode(',', $context['pmx']['areas']))) {
        loadJavascriptFile(PortaMx_loadCompressed('PortaMxAdmin.js'), array('external' => true));
        loadCSSFile(PortaMx_loadCompressed('portamx_admin.css'), array('external' => true));
        loadLanguage($context['pmx_templatedir'] . 'Admin');
        addInlineJavascript("\n\t" . 'BlockActive=\'' . $txt['pmx_status_activ'] . ' - ' . $txt['pmx_status_change'] . '\';' . "\n\t" . 'BlockInactive=\'' . $txt['pmx_status_inactiv'] . ' - ' . $txt['pmx_status_change'] . '\';');
    }
    // Error request?
    if (!empty($_REQUEST['pmxerror'])) {
        return PmxError();
    }
    // check Error request, Forum request
    $context['pmx']['forumReq'] = !empty($_REQUEST['action']) || !empty($context['current_board']) || !empty($context['current_topic']);
    if (empty($context['pmx']['forumReq']) && !empty($context['pmx']['settings']['other_actions'])) {
        $reqtyp = Pmx_StrToArray($context['pmx']['settings']['other_actions']);
        foreach ($reqtyp as $rtyp) {
            @(list($rtyp, $rval) = Pmx_StrToArray($rtyp, '='));
            $context['pmx']['forumReq'] = $context['pmx']['forumReq'] || isset($_REQUEST[$rtyp]) && (is_null($rval) || $_REQUEST[$rtyp] == $rval);
        }
    }
    // check Page, category, article request
    $pmxRequestTypes = array('spage', 'art', 'cat', 'child');
    $context['pmx']['pageReq'] = array();
    foreach ($pmxRequestTypes as $type) {
        if (empty($_REQUEST['action']) && !empty($_REQUEST[$type])) {
            $context['pmx']['pageReq'][$type] = PortaMx_makeSafe($_REQUEST[$type]);
        }
    }
    // no request on forum or pages and no frontpage .. go to forum
    if (empty($context['pmx']['forumReq']) && empty($context['pmx']['pageReq']) && $context['pmx']['settings']['frontpage'] == 'none') {
        $_REQUEST['action'] = $_GET['action'] = 'community';
        $context['pmx']['forumReq'] = true;
    }
    // Disable HighSlide on action?
    if (isset($_REQUEST['action']) && isset($context['pmx']['settings']['noHS_onaction'])) {
        $noHighSlide = isset($context['pmx']['settings']['noHS_onaction']) ? Pmx_StrToArray($context['pmx']['settings']['noHS_onaction']) : array();
        if (in_array($_REQUEST['action'], $noHighSlide)) {
            $context['pmx']['settings']['disableHS'] = 1;
        }
    }
    // Admin panel/block hidding ?
    $hideRequest = array_intersect($context['pmx']['extracmd'], array_keys($_REQUEST));
    if (!empty($hideRequest) && allowPmx('pmx_admin')) {
        @(list($hideRequest) = array_values($hideRequest));
        $mode = substr($hideRequest, 5);
        $hidetyp = substr($hideRequest, 0, 5);
        $offparts = empty($modSettings['pmx_' . $hidetyp . 'off']) ? array() : Pmx_StrToArray($modSettings['pmx_' . $hidetyp . 'off']);
        if ($mode == 'off') {
            if ($hidetyp == 'panel') {
                $offparts = array_intersect($_REQUEST[$hideRequest] == 'all' ? $context['pmx']['block_sides'] : array_merge($offparts, Pmx_StrToArray($_REQUEST[$hideRequest])), $context['pmx']['block_sides']);
            } else {
                $offparts = array_merge($offparts, Pmx_StrToIntArray($_REQUEST[$hideRequest]));
            }
        } else {
            if ($hidetyp == 'panel') {
                $offparts = array_intersect($_REQUEST[$hideRequest] == 'all' ? array() : array_diff($offparts, Pmx_StrToArray($_REQUEST[$hideRequest])), $context['pmx']['block_sides']);
            } else {
                $offparts = $_REQUEST[$hideRequest] == 'all' ? array() : array_diff($offparts, Pmx_StrToIntArray($_REQUEST[$hideRequest]));
            }
        }
        updateSettings(array('pmx_' . $hidetyp . 'off' => implode(',', $offparts)));
        unset($_GET[$hideRequest]);
        redirectexit(pmx_http_build_query($_GET));
    }
    // check all the actions and more...
    if (empty($context['pmx']['forumReq'])) {
        // if a redirect request, exit
        $requrl = strpos($_SERVER['REQUEST_URL'], substr($scripturl, 0, strrpos($scripturl, '/'))) === false ? $_SERVER['REQUEST_URL'] : $scripturl;
        if (substr($requrl, 0, strrpos($requrl, '/')) != substr($scripturl, 0, strrpos($scripturl, '/'))) {
            return;
        }
        // we use the frontpage ?
        $useFront = $context['pmx']['settings']['frontpage'] == 'none' && empty($context['pmx']['pageReq']) ? '' : 'frontpage';
        // get all block on active panels they can view
        $context['pmx']['viewblocks'] = getPanelsToShow($useFront);
        // frontpage and/or Page blocks exist ?
        if (!empty($maintenance) && $context['pmx']['settings']['frontpage'] != 'none' || empty($useFront) || !empty($context['pmx']['show_pagespanel']) || !empty($context['pmx']['show_frontpanel']) && $context['pmx']['settings']['frontpage'] != 'none') {
            // setup headers
            PortaMx_headers('frontpage');
            $context['robot_no_index'] = empty($context['pmx']['settings']['indexfront']);
            if ($context['pmx']['settings']['frontpage'] == 'fullsize') {
                loadTemplate($context['pmx_templatedir'] . 'Frontpage');
                $context['template_layers'] = array('fronthtml', 'portamx');
                call_integration_hook('integrate_load_theme');
            } else {
                loadTemplate($context['pmx_templatedir'] . 'Mainindex');
                $context['template_layers'][] = 'portamx';
            }
            if (!empty($context['pmx']['pageReq']) || empty($context['pmx']['forumReq']) && $context['pmx']['settings']['frontpage'] != 'none') {
                loadTemplate($context['pmx_templatedir'] . 'PortaMx');
            }
        } else {
            // page req error?
            if (!empty($context['pmx']['pageReq']) && empty($context['pmx']['show_pagespanel'])) {
                redirectexit('pmxerror=page');
            }
            // else go to forum
            $_REQUEST['action'] = $_GET['action'] = !empty($maintenance) && empty($user_info['is_admin']) ? '' : 'community';
            $context['pmx']['forumReq'] = true;
            $context['pmx']['viewblocks'] = null;
        }
    }
    if (!empty($context['pmx']['forumReq'])) {
        // get the action
        $action = isset($_REQUEST['action']) ? $_REQUEST['action'] == 'collapse' ? 'community' : $_REQUEST['action'] : (isset($_REQUEST['board']) ? 'boards' : (isset($_REQUEST['topic']) ? 'topics' : ''));
        // get all block on active panels they can view
        $context['pmx']['viewblocks'] = getPanelsToShow($action);
        // setup headers
        PortaMx_headers($action);
        // load the "Main" template on pages, cats or arts
        if (!empty($context['pmx']['pageReq'])) {
            loadTemplate($context['pmx_templatedir'] . 'PortaMx');
        }
        loadTemplate($context['pmx_templatedir'] . 'Mainindex');
        $context['template_layers'][] = 'portamx';
    }
    // Load the Frame template
    loadTemplate($context['pmx_templatedir'] . 'Frames');
    // supress these links if ECL not accepted
    if (!empty($rqaction) && !pmx_checkECL_Cookie() && isset($modSettings['pmx_eclmodalaction']) && in_array($rqaction, Pmx_StrToArray($modSettings['pmx_eclmodalaction']))) {
        pmx_ECL_Error('request');
    }
    // Create the linktree
    return pmx_MakeLinktree();
}
/**
* pmx_handle_xml - Handle xml action requests
**/
function pmx_handle_xml()
{
    global $context, $boardurl, $modSettings, $boarddir, $pmxCacheFunc;
    if (isset($_REQUEST['getcookie'])) {
        if ($_REQUEST['name'] == 'ecl_auth' && isset($_REQUEST['value']) && $_REQUEST['value'] == 'checkECL') {
            $result = pmx_checkECL_Cookie($_REQUEST['sender'] == 'reqOverlay');
        } else {
            $result = pmx_getcookie($_REQUEST['name']);
        }
    } else {
        if (isset($_REQUEST['setcookie'])) {
            // php syntax check?
            if ($_REQUEST['name'] == 'pmx_php_check') {
                $context['pmx_imageurl'] = $boardurl . '/Themes/default/PortaMx/SysCss/Images/';
                $result = PortaMx_PHPsyntax($_REQUEST['value']);
            } else {
                $result = 'ok';
                if ($_REQUEST['name'] == 'pmx_eclauth') {
                    pmx_setECL_Cookie();
                } else {
                    pmx_setcookie($_REQUEST['name'], $_REQUEST['value']);
                }
            }
        }
    }
    ob_start();
    echo $result;
    ob_end_flush();
    exit;
}
    /**
     * Get category and his childs
     */
    function getCatsAndChilds($cats, $acs, $acs_inherit = false)
    {
        global $context, $smcFunc;
        $catIDs = array();
        $catNames = array();
        $this->categories = array();
        $corder = $cats['catorder'];
        $cat = PortaMx_getCatByOrder(array($cats), $corder);
        while (is_array($cat)) {
            if (!is_array($cat['config'])) {
                $cat['config'] = unserialize($cat['config']);
            }
            // check ecl
            if (empty($cat['config']['check_ecl']) || !empty($cat['config']['check_ecl']) && pmx_checkECL_Cookie(!empty($cat['config']['check_eclbots']))) {
                if (!empty($cat['artsum'])) {
                    // get custom css if set
                    if (!empty($cat['config']['cssfile'])) {
                        $this->getCustomCSS($cat);
                    }
                    // inherit acs from block?
                    if (!empty($acs_inherit)) {
                        $cat['acsgrp'] = $acs;
                    }
                    if (allowPmxGroup($cat['acsgrp'])) {
                        $ttl = $this->getUserTitle($cat);
                        if (empty($ttl)) {
                            $ttl = htmlspecialchars($cat['name'], ENT_QUOTES);
                        }
                        $this->categories[$cat['name']] = array('id' => $cat['id'], 'name' => $cat['name'], 'artsort' => $cat['artsort'], 'acsgrp' => $cat['acsgrp'], 'config' => $cat['config'], 'side' => $this->cfg['side'], 'blocktype' => 'category', 'customclass' => '', 'title' => $ttl);
                        $catIDs[] = $cat['id'];
                        $catNames[$cat['id']] = $cat['name'];
                    }
                }
            } else {
                break;
            }
            $addSub = !empty($cat['config']['settings']['addsubcats']) && $cat['config']['settings']['showmode'] == 'sidebar' || !empty($cat['config']['settings']['showsubcats']) && $cat['config']['settings']['showmode'] == 'pages';
            if (!empty($addSub)) {
                $corder = PortaMx_getNextCat($corder);
                $cat = PortaMx_getCatByOrder(array($cats), $corder);
            } else {
                break;
            }
        }
        if (!empty($catIDs)) {
            // get articles for any cat
            $request = $smcFunc['db_query']('', '
				SELECT a.id, a.name, a.acsgrp, a.catid, a.ctype, a.config, a.owner, a.active, a.created, a.updated, a.approved, a.content, CASE WHEN m.real_name = {string:empty} THEN m.member_name ELSE m.real_name END AS mem_name
				FROM {db_prefix}portamx_articles AS a
				LEFT JOIN {db_prefix}members AS m ON (a.owner = m.id_member)
				WHERE a.catid IN ({array_int:cats}) AND a.active > 0 AND a.approved > 0
				ORDER BY a.id', array('cats' => $catIDs, 'empty' => ''));
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                $row['config'] = unserialize($row['config']);
                // check ecl
                if (empty($row['config']['check_ecl']) || !empty($row['config']['check_ecl']) && pmx_checkECL_Cookie(!empty($row['config']['check_eclbots']))) {
                    if (!empty($this->categories[$catNames[$row['catid']]]['config']['settings']['inherit_acs'])) {
                        $row['acsgrp'] = $this->categories[$catNames[$row['catid']]]['acsgrp'];
                    }
                    if (allowPmxGroup($row['acsgrp'])) {
                        if (!empty($this->categories[$catNames[$row['catid']]]['config']['settings']['catstyle'])) {
                            $row['config']['visuals'] = $this->categories[$catNames[$row['catid']]]['config']['visuals'];
                            $row['config']['cssfile'] = $this->categories[$catNames[$row['catid']]]['config']['cssfile'];
                        }
                        $row['side'] = $this->cfg['side'];
                        $row['blocktype'] = !empty($this->cfg['config']) ? 'static_article' : 'article';
                        $row['member_name'] = $row['mem_name'];
                        // get custom css if set
                        if (!empty($row['config']['cssfile'])) {
                            $this->getCustomCSS($row);
                        }
                        $this->articles[$catNames[$row['catid']]][] = $row;
                    }
                }
            }
            $smcFunc['db_free_result']($request);
        }
        // articles found?
        $ccats = $this->categories;
        foreach ($ccats as $cname => $cdata) {
            if (!empty($this->articles[$cname])) {
                $this->articles[$cname] = PortaMx_ArticleSort($this->articles[$cname], $this->categories[$cname]['artsort']);
                // if article reqested, get the tile
                if (!empty($this->postarray[$this->postKey]['art']) && $cname == (empty($this->postarray[$this->postKey]['child']) ? $this->postarray[$this->postKey]['cat'] : $this->postarray[$this->postKey]['child'])) {
                    foreach ($this->articles[$cname] as $art) {
                        if ($art['name'] == $this->postarray[$this->postKey]['art']) {
                            $context['pmx']['pagenames']['art'] = $this->getUserTitle($art);
                            if (empty($context['pmx']['pagenames']['art'])) {
                                $context['pmx']['pagenames']['art'] = htmlspecialchars($art['name'], ENT_QUOTES);
                            }
                            break;
                        }
                    }
                }
            } else {
                unset($this->categories[$cname]);
            }
        }
    }
 /**
  * The Contructor.
  * Saved the config and checks the visiblity access.
  * If access true, the block css file is loaded if exist.
  */
 function PortaMxC_Blocks($blockconfig, &$visible)
 {
     global $context, $modSettings, $maintenance;
     // load the config
     if (isset($blockconfig['config'])) {
         $blockconfig['config'] = unserialize($blockconfig['config']);
     }
     $this->cfg = $blockconfig;
     $visible = !empty($this->cfg['active']);
     // check if ecl set
     $visible = empty($this->cfg['config']['check_ecl']) || !empty($this->cfg['config']['check_ecl']) && pmx_checkECL_Cookie(!empty($this->cfg['config']['check_eclbots']));
     if (!empty($visible)) {
         // hide on maintenance?
         if (!empty($maintenance) && !empty($this->cfg['config']['maintenance_mode'])) {
             $visible = false;
         }
         if (isset($this->cfg['config']['static_block'])) {
             $this->cfg['static_block'] = $this->cfg['config']['static_block'];
         }
         $this->startpage = 0;
         $this->inBlockCall = $this->cfg['side'] == 'bib';
         $this->cfg['uniID'] = 'blk' . $this->cfg['id'] . (!empty($this->inBlockCall) ? '-0' : '');
         // set the cache_key, cache time and trigger
         $this->cache_key = $this->cfg['blocktype'] . $this->cfg['id'];
         if (in_array($this->cfg['blocktype'], array_keys($context['pmx']['cache']['blocks']))) {
             $this->cache_mode = $context['pmx']['cache']['blocks'][$this->cfg['blocktype']]['mode'];
             $this->cache_time = $context['pmx']['cache']['blocks'][$this->cfg['blocktype']]['time'];
             if ($context['pmx']['cache']['blocks'][$this->cfg['blocktype']]['trigger'] == 'default') {
                 $this->cache_trigger = $context['pmx']['cache']['default']['trigger'];
             } else {
                 $this->cache_trigger = $context['pmx']['cache']['blocks'][$this->cfg['blocktype']]['trigger'];
             }
             // call cache trigger
             $this->cache_status = $this->pmxc_checkCacheStatus();
             if (!empty($this->cache_status['action'])) {
                 $visible = false;
             }
         } else {
             $this->cache_mode = false;
             $this->cache_time = 3600;
             $this->cache_trigger = '';
         }
         // check the block visible access if not a BIB block ($this->inBlockCall = true)
         if ($visible && empty($this->inBlockCall)) {
             // check group access only, if we not in admin section
             if (isset($_GET['area']) != 'pmx_blocks') {
                 if (isset($this->cfg['inherit_acs'])) {
                     $visible = !empty($this->cfg['inherit_acs']) || allowPmxGroup($this->cfg['acsgrp']);
                 } else {
                     $visible = allowPmxGroup($this->cfg['acsgrp']);
                 }
             }
             // Show "Home - Community" Buttons?
             if ($visible && $context['pmx']['settings']['frontpage'] != 'none' && $this->cfg['side'] == 'front') {
                 $context['pmx']['showhome'] += 1;
             }
             // hide block on request?
             if (!empty($context['pmx']['pageReq']) && $this->cfg['side'] == 'front' && $this->cfg['config']['frontplace'] == 'hide') {
                 $visible = false;
             }
             // disable frontpage blocks before init if the frontpage not shown
             if ($visible && $this->cfg['side'] == 'front' && empty($context['pmx']['pageReq']) && !empty($_GET)) {
                 $visible = false;
             }
             // hide frontblock on pagerequest?
             if ($visible && $this->cfg['side'] == 'front' && array_key_exists('spage', $context['pmx']['pageReq'])) {
                 $visible = empty($this->cfg['config']['frontplace']) || !empty($this->cfg['config']['frontplace']) && $this->cfg['config']['frontplace'] != 'hide';
             }
             // check page request
             if ($visible && $this->cfg['side'] == 'pages') {
                 $visible = !empty($context['pmx']['pageReq']) || empty($context['pmx']['forumReq']);
                 if (!empty($this->cfg['config']['static_block']) || !in_array($this->cfg['blocktype'], array('article', 'category'))) {
                     $this->cfg['config']['ext_opts']['pmxcust'] .= empty($this->cfg['config']['ext_opts']['pmxcust']) ? '@' : '';
                 }
             }
             // check dynamic visibility options
             if ($visible && !empty($this->cfg['config']['ext_opts'])) {
                 // check mobile / desktop devices
                 if (!empty($this->cfg['config']['ext_opts']['device'])) {
                     if (!empty($modSettings['pmx_isMobile']) && $this->cfg['config']['ext_opts']['device'] != '1') {
                         $visible = false;
                     }
                     if (empty($modSettings['pmx_isMobile']) && $this->cfg['config']['ext_opts']['device'] != '2') {
                         $visible = false;
                     }
                 }
                 // continue on other visibility options
                 if ($visible) {
                     $visible = pmx_checkExtOpts(true, $this->cfg['config']['ext_opts'], isset($this->cfg['config']['pagename']) ? $this->cfg['config']['pagename'] : '');
                 }
             }
             // continue if the block visible
             if ($visible) {
                 // if Page block and have a frontpage switch?
                 if (empty($context['pmx']['forumReq']) && $this->cfg['side'] == 'pages' && !empty($this->cfg['config']['frontmode'])) {
                     $context['pmx']['settings']['frontpage'] = $this->cfg['config']['frontmode'];
                 }
                 // check block display on frontpage mode
                 if (!empty($this->cfg['config']['frontview']) && !in_array($this->cfg['side'], array('front', 'pages'))) {
                     $visible = empty($context['pmx']['forumReq']) && $this->cfg['config']['frontview'] == $context['pmx']['settings']['frontpage'];
                 }
             }
         } else {
             if (!empty($visible)) {
                 $visible = pmx_checkExtOpts(true, $this->cfg['config']['ext_opts'], $this->cfg['config']['pagename']);
             }
         }
         // if visible check for a custom cssfile
         if (!empty($visible)) {
             $this->getCustomCSS($this->cfg);
         }
         if (!empty($visible) && $this->cfg['side'] == 'pages' && array_key_exists('spage', $context['pmx']['pageReq'])) {
             $context['pmx']['pagenames']['spage'] = $this->getUserTitle();
             if (empty($context['pmx']['pagenames']['spage'])) {
                 $context['pmx']['pagenames']['spage'] = htmlspecialchars($this->cfg['config']['pagename'], ENT_QUOTES);
             }
         }
     }
     $this->visible = $visible;
 }
    /**
     * InitContent.
     * Checks the cache status and create the content.
     */
    function pmxc_InitContent()
    {
        global $context, $smcFunc, $pmxCacheFunc;
        // if visible init the content
        if ($this->visible) {
            // called from static article block?
            if (!empty($this->cfg['config']['static_block'])) {
                $this->cfg['name'] = $this->cfg['config']['settings']['article'];
                $this->cfg['blocktype'] = 'artblock';
                if ($this->cfg['config']['settings']['usedframe'] == 'article') {
                    $this->cfg['config']['skip_outerframe'] = true;
                }
                $this->cfg['config']['visuals']['bodytext'] = '';
                if (!empty($this->cfg['cache'])) {
                    $this->articles = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode);
                } else {
                    $this->articles = array();
                }
                $this->printID = 'artblk' . $this->cfg['id'];
            } else {
                $this->cache_key = 'req' . $this->cache_key;
                $this->articles = array();
                $this->cfg['config']['skip_outerframe'] = true;
                $this->cfg['config']['settings']['usedframe'] = 'article';
                $this->printID = 'artreq' . $this->cfg['id'];
            }
            // get the articles
            if (empty($this->articles)) {
                if (!empty($this->cfg['name'])) {
                    $request = $smcFunc['db_query']('', '
						SELECT a.id, a.name, a.acsgrp, a.ctype, a.config, a.owner, a.active, a.created, a.updated, a.content, CASE WHEN m.real_name = {string:empty} THEN m.member_name ELSE m.real_name END AS mem_name
						FROM {db_prefix}portamx_articles AS a
						LEFT JOIN {db_prefix}members AS m ON (a.owner = m.id_member)
						WHERE a.name = {string:art} AND a.active > 0 AND a.approved > 0
						ORDER BY a.id', array('art' => $this->cfg['name'], 'empty' => ''));
                    if ($smcFunc['db_num_rows']($request) > 0) {
                        while ($row = $smcFunc['db_fetch_assoc']($request)) {
                            $row['config'] = unserialize($row['config']);
                            if (!empty($this->cfg['config']['settings']['inherit_acs'])) {
                                $row['acsgrp'] = $this->cfg['acsgrp'];
                            }
                            if (allowPmxGroup($row['acsgrp'])) {
                                // have a custom cssfile, load
                                if (!empty($row['config']['cssfile'])) {
                                    $this->getCustomCSS($row);
                                } else {
                                    $row['customclass'] = '';
                                }
                                $row['side'] = $this->cfg['side'];
                                $row['blocktype'] = !empty($this->cfg['config']['static_block']) ? 'static_article' : 'article';
                                $row['member_name'] = $row['mem_name'];
                                $this->articles[] = $row;
                            }
                        }
                        $smcFunc['db_free_result']($request);
                    }
                    // static block?
                    if (!empty($this->cfg['config']['static_block']) && !empty($this->cfg['cache'])) {
                        $pmxCacheFunc['put']($this->cache_key, $this->articles, $this->cache_time, $this->cache_mode);
                    }
                }
            }
            // articles found?
            if (count($this->articles) > 0) {
                // ecl check
                foreach ($this->articles as $aKey => $aVal) {
                    if (!empty($this->articles[$aKey]['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($this->articles[$aKey]['config']['check_eclbots']))) {
                        unset($this->articles[$aKey]);
                    } else {
                        // static article block ?
                        if (!empty($this->cfg['config']['static_block'])) {
                            $this->cfg['blocktype'] = 'artblock';
                            if ($this->cfg['config']['settings']['usedframe'] == 'block') {
                                $this->articles[$aKey]['config']['visuals'] = $this->cfg['config']['visuals'];
                                $this->articles[$aKey]['config']['cssfile'] = $this->cfg['config']['cssfile'];
                            }
                        } else {
                            $context['pmx']['pagenames']['art'] = $this->getUserTitle($this->articles[0], $this->articles[0]['name']);
                        }
                    }
                }
            }
            $this->visible = count($this->articles) > 0;
            if (!empty($this->visible)) {
                // check for special php content
                foreach ($this->articles as $art) {
                    if ($art['ctype'] == 'php' && preg_match('~\\[\\?pmx_initphp(.*)pmx_initphp\\?\\]~is', $art['content'], $match)) {
                        eval($match[1]);
                    }
                }
            }
        }
        return $this->visible;
    }
Ejemplo n.º 7
0
    /**
     * Create_polldata.
     * Get the poll data and save it to the content.
     */
    function Create_polldata()
    {
        global $smcFunc, $user_info, $modSettings, $txt;
        $this->polls = array();
        $this->pollquestions = array();
        $this->polldata = array();
        $this->currentpoll = array('id' => 0, 'state' => 0);
        // ckeck if a pollcookie exist
        $cookname = 'poll' . $this->cfg['id'];
        if (($cook = pmx_getcookie($cookname)) && !is_null($cook)) {
            $tmp = explode(',', $cook);
            if (count($tmp) == 2) {
                $this->currentpoll = array('id' => (int) $tmp[0], 'state' => (int) $tmp[1]);
            } else {
                $this->currentpoll = array('id' => 0, 'state' => 0);
            }
        }
        // member has voted?
        $membervote = array();
        $request = $smcFunc['db_query']('', '
				SELECT id_poll
				FROM {db_prefix}log_polls
				WHERE id_poll IN ({array_int:polls}) AND id_member = {int:current_member}', array('polls' => $this->cfg['config']['settings']['polls'], 'current_member' => $user_info['id']));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            $membervote[$row['id_poll']] = true;
        }
        $smcFunc['db_free_result']($request);
        // get all poll data
        $request = $smcFunc['db_query']('', '
				SELECT t.id_topic, b.id_board, p.id_poll, p.question, p.voting_locked, p.hide_results, p.expire_time, p.guest_vote, p.change_vote, p.num_guest_voters
				FROM {db_prefix}topics AS t
				INNER JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
				INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
				WHERE t.id_poll IN ({array_int:polls})
					AND {query_see_board} ' . (!in_array(0, $this->boardsAllowed) ? '
					AND b.id_board IN ({array_int:boards_allowed_see})' : '') . ($modSettings['postmod_active'] ? '
					AND t.approved = {int:is_approved}' : '') . '
				ORDER BY t.id_poll DESC', array('polls' => $this->cfg['config']['settings']['polls'], 'boards_allowed_see' => $this->boardsAllowed, 'is_approved' => 1));
        if ($smcFunc['db_num_rows']($request) > 0) {
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                $pid = array_search($row['id_poll'], $this->cfg['config']['settings']['polls']);
                if (is_numeric($pid)) {
                    // can vote?
                    if (pmx_checkECL_Cookie(true)) {
                        $cook = isset($_COOKIE['guest_poll_vote']) ? $_COOKIE['guest_poll_vote'] : '';
                        if (!empty($row['expire_time']) && $row['expire_time'] < time()) {
                            $allow_vote = false;
                        } elseif ($user_info['is_guest'] && $row['guest_vote'] && (empty($cook) || !empty($cook) && preg_match('~^[0-9,;]+$~', $cook) && strpos($cook, ';' . $row['id_poll'] . ',') === false)) {
                            $allow_vote = true;
                        } elseif ($user_info['is_guest']) {
                            $allow_vote = false;
                        } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) {
                            $allow_vote = false;
                        } else {
                            $allow_vote = !isset($membervote[$row['id_poll']]);
                        }
                    } else {
                        $allow_vote = false;
                    }
                    // poll expired
                    $is_expired = !empty($row['expire_time']) && $row['expire_time'] < time();
                    $is_locked = !empty($row['voting_locked']);
                    // can view?
                    $allow_view_results = allowedTo('moderate_board') || $row['hide_results'] == 0 || $row['hide_results'] == 1 && !$allow_vote || $is_expired || $is_locked;
                    // save data
                    $this->polldata[$pid] = array('is_locked' => $is_locked, 'allow_vote' => $allow_vote && !$is_expired && !$is_locked, 'allow_view_results' => $allow_view_results, 'allow_change_vote' => !$is_expired && !$is_locked && !$user_info['is_guest'] && !$allow_vote && !empty($row['change_vote']), 'is_expired' => $is_expired, 'expired' => !empty($row['expire_time']) ? timeformat($row['expire_time']) : 0, 'guestvotes' => $row['num_guest_voters']);
                    $polltopic[$pid] = $row['id_topic'];
                    $this->pollquestions[$pid] = $row['question'];
                }
            }
            $smcFunc['db_free_result']($request);
            // secure...
            if (!isset($polltopic[$this->currentpoll['id']])) {
                $this->currentpoll = array('id' => 0, 'state' => 0);
                $polltopic[$this->currentpoll['id']] = 0;
            }
            // get poll data
            $request = $smcFunc['db_query']('', '
					SELECT p.id_poll, p.question, p.max_votes
					FROM {db_prefix}topics AS t
					INNER JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
					WHERE t.id_topic = {int:current_topic}', array('current_topic' => $polltopic[$this->currentpoll['id']]));
            // get Member votes
            if ($smcFunc['db_num_rows']($request) > 0) {
                $row = $smcFunc['db_fetch_assoc']($request);
                $smcFunc['db_free_result']($request);
                $request = $smcFunc['db_query']('', '
						SELECT COUNT(DISTINCT id_member)
						FROM {db_prefix}log_polls
						WHERE id_poll = {int:current_poll} AND id_member != 0', array('current_poll' => $row['id_poll']));
                list($total_votes) = $smcFunc['db_fetch_row']($request);
                $smcFunc['db_free_result']($request);
                $request = $smcFunc['db_query']('', '
						SELECT id_choice, label, votes
						FROM {db_prefix}poll_choices
						WHERE id_poll = {int:current_poll}', array('current_poll' => $row['id_poll']));
                $polloptions = array();
                $total = 0;
                while ($rowChoice = $smcFunc['db_fetch_assoc']($request)) {
                    censorText($rowChoice['label']);
                    $polloptions[$rowChoice['id_choice']] = array($rowChoice['label'], $rowChoice['votes']);
                    $total += $rowChoice['votes'];
                }
                $smcFunc['db_free_result']($request);
                $total_votes += $this->polldata[$this->currentpoll['id']]['guestvotes'];
                $this->polls = array('id' => $row['id_poll'], 'question' => $row['question'], 'total_votes' => $total_votes, 'topic' => $polltopic[$this->currentpoll['id']]);
                $this->polls = array_merge($this->polls, $this->polldata[$this->currentpoll['id']]);
                // Calculate the percentages ..
                $divisor = $total == 0 ? 1 : $total;
                $tablen = 1;
                foreach ($polloptions as $i => $opt) {
                    $bar = floor($opt[1] * 100 / $divisor);
                    $tablen = $tablen < $bar ? $bar : $tablen;
                    $this->polls['options'][$i] = array('id' => 'options' . $this->cfg['id'] . '-' . $i, 'percent' => round($opt[1] * 100 / $divisor, 1), 'votes' => $opt[1], 'option' => parse_bbc($opt[0]), 'vote_button' => '<input type="' . ($row['max_votes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options' . $this->cfg['id'] . '-' . $i . '" value="' . $i . '" class="' . ($row['max_votes'] > 1 ? 'input_check' : 'input_radio') . '" />');
                }
                $this->polls['allowed_warning'] = $row['max_votes'] > 1 ? sprintf($txt['poll_options6'], min(count($opt), $row['max_votes'])) : '';
                $this->polls['tablen'] = (int) $tablen;
            } else {
                $this->visible = false;
            }
            // hide the block
        } else {
            $this->visible = false;
        }
        // hide the block
    }
    /**
     * ShowContent
     */
    function pmxc_ShowContent()
    {
        global $context, $scripturl, $user_info, $txt;
        $context['pmx']['shout_edit'] = -1;
        // smiley && bb codes popup
        $innerPad = Pmx_getInnerPad($this->cfg['config']['innerpad']);
        $bodyclass = $this->cfg['config']['visuals']['body'] == 'windowbg' ? 'windowbg2 ' : 'windowbg ';
        echo '
			<div id="bbcodes' . $this->cfg['id'] . '" style="position:absolute;z-index:9999;width:340px;height:110px;display:none">
				<div>
					<div class="' . $bodyclass . ' roundframe shoutbox_round ' . str_replace('pmxborder', '', $this->cfg['config']['visuals']['frame']) . '" style="margin:auto;text-align:center;border-radius:6px;border-width:1px;box-shadow:none;">';
        echo '
						<div style="height:25px;">';
        $half = 10;
        foreach ($this->smileys as $sm) {
            echo '
						<img onclick="InsertSmiley(' . $this->cfg['id'] . ', \'' . addslashes($sm['code']) . '\')" src="' . $sm['image'] . '" alt="*" title="' . $sm['title'] . '" style="float:left;cursor:pointer;padding:2px 7px;" />';
            $half--;
            if ($half == 0) {
                echo '
						</div>
						<div style="height:25px;">';
            }
        }
        echo '
						</div>
						<hr class="pmx_hr" />
						<div style="height:28px;">';
        foreach ($this->bb_code as $sm) {
            echo '
							<img onclick="InsertBBCode(' . $this->cfg['id'] . ', \'' . $sm['code'] . '\'); return false;" src="' . $sm['image'] . '" alt="*" title="' . $sm['title'] . '" class="shoutbox_bbcimg" />';
        }
        echo '
							<select id="shout_color' . $this->cfg['id'] . '" size="1" onchange="InsertBBColor(' . $this->cfg['id'] . ', this); return false;" style="float:right; margin:3px 4px 0 0px; width:100px;">';
        foreach ($this->bb_colors as $coltxt => $colname) {
            echo '
								<option value="' . $colname . '"' . ($colname == $coltxt ? ' selected="selected"' : '') . '>' . $coltxt . '</option>';
        }
        echo '
							</select>
						</div>
					</div>
				</div>
			</div>';
        echo '
			<div class="' . $this->cfg['side'] . '" id="shoutframe' . $this->cfg['id'] . '" style="' . (isset($this->cfg['config']['settings']['maxheight']) ? 'max-height:' . $this->cfg['config']['settings']['maxheight'] . 'px; overflow:auto; ' : '') . 'padding:0px;">';
        $haveshouts = false;
        $allowAdmin = allowPmx('pmx_admin');
        $cnt = 0;
        foreach ($this->shouts as $id => $data) {
            echo '
				<div id="shoutitem' . $this->cfg['id'] . '-' . $id . '">
					<div class="tborder shoutbox_user">';
            // show the edit/delete images
            if ($allowAdmin || $user_info['id'] == $data['uid'] && !empty($this->cfg['config']['settings']['allowedit']) && $this->canShout) {
                $haveshouts = $allowAdmin || $user_info['id'] == $data['uid'] ? true : $haveshouts;
                echo '
						<img id="' . $cnt . 'shoutimg' . $this->cfg['id'] . '" onclick="DeleteShout(' . $this->cfg['id'] . ', ' . $id . ', ' . intval(!empty($this->cfg['config']['settings']['boxcollapse'])) . ', ' . intval(!empty($this->cfg['config']['settings']['boxcollapse'])) . ');" style="cursor:pointer; margin-top:2px; display:none;float:right;margin-right:2px;" src="' . $context['pmx_imageurl'] . 'shout_del.gif" alt="*" title="' . $txt['pmx_shoutbox_shoutdelete'] . '" />';
                $cnt++;
                echo '
						<img id="' . $cnt . 'shoutimg' . $this->cfg['id'] . '" onclick="EditShout(' . $this->cfg['id'] . ', ' . $id . ', \'' . addslashes($data['post']) . '\');" style="cursor:pointer;margin-top:2px;padding-right:4px;display:none;float:right;" src="' . $context['pmx_imageurl'] . 'shout_edit.gif" alt="*" title="' . $txt['pmx_shoutbox_shoutedit'] . '" />';
                $cnt++;
            }
            // show the ip image
            if ($allowAdmin && !empty($data['ip'])) {
                echo '
						<a id="' . $cnt . 'shoutimg' . $this->cfg['id'] . '" href="' . $scripturl . '?action=trackip;searchip=' . $data['ip'] . '" style="display:none;">
							<img src="' . $context['pmx_imageurl'] . 'ip.gif" style="padding:4px 3px 0 0;float:right;margin-top:-3px;" title="' . $data['ip'] . '" alt="*" />
						</a>';
                $cnt++;
            }
            // convert smileys and bb codes
            $data['post'] = $this->BBCtoHTML($data['post'], true);
            // Guest shout?
            if ($data['uid'] != 0 && isset($this->memdata[$data['uid']])) {
                echo '
						<a style="display:block; margin-top:-2px;" href="' . $scripturl . '?action=profile;u=' . $data['uid'] . '"><span' . (isset($this->memdata[$data['uid']]['color']) && !empty($this->memdata[$data['uid']]['color']) ? ' style="color:' . $this->memdata[$data['uid']]['color'] . ';"' : '') . '>' . $this->memdata[$data['uid']]['name'] . '</span></a>';
            } else {
                $data['uid'] = 0;
                echo '
						' . $this->memdata[$data['uid']]['name'];
            }
            echo '<div class="smalltext shoutbox_date">' . timeformat($data['time']) . '</div>
					</div>
					<div class="shoutbox_post">
						' . $data['post'] . '
					</div>
				</div>';
        }
        echo '
				<input type="hidden" id="shoutcount' . $this->cfg['id'] . '" value="' . $cnt . '" />
			</div>';
        // have shout access?
        if ($this->canShout) {
            $canEdit = !$user_info['is_guest'] && ($allowAdmin && $haveshouts || $haveshouts && !empty($this->cfg['config']['settings']['allowedit']));
            $Admimg[0] = $context['pmx_imageurl'] . ($canEdit ? 'shout_admon.gif' : 'empty.gif');
            $Admimg[1] = $context['pmx_imageurl'] . ($canEdit ? 'shout_admoff.gif' : 'empty.gif');
            if (pmx_checkECL_Cookie(true)) {
                echo '
			<div style="overflow:hidden;margin-bottom:2px;margin-top:4px;">
				<input type="hidden" name="shoutbox_action" value="shout" />
				<input type="hidden" name="shoutbox_id" value="' . $this->cfg['id'] . '" />
				<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
				<input type="hidden" id="shout' . $this->cfg['id'] . '" name="pmx_shout" value="" />
				<input type="hidden" id="shoutid' . $this->cfg['id'] . '" name="shoutid" value="" />
				<div id="shoutcontdiv' . $this->cfg['id'] . '" style="display:none;">
					<textarea id="shoutcontent' . $this->cfg['id'] . '"  style="height:80px;min-height:80px;max-height:250px;width:100%;resize:vertical;" name="post"></textarea>
				</div>
				<div style="border-top:1px solid #ddd;margin-top:2px;padding-top:2px;">
					<img id="shoutbbon' . $this->cfg['id'] . '" style="cursor:pointer;margin-top:6px;float:left;' . (!empty($this->cfg['config']['settings']['boxcollapse']) ? 'display:none;' : '') . '" onclick="ShoutPopup(' . $this->cfg['id'] . ');" src="' . $context['pmx_imageurl'] . 'type_bbc.gif" alt="*" title="' . $txt['pmx_shoutbox_bbc_code'] . '" />';
                if (!empty($this->cfg['config']['settings']['boxcollapse'])) {
                    echo '
					<img id="shoutbboff' . $this->cfg['id'] . '" style="margin-top:6px;float:left;" src="' . $context['pmx_imageurl'] . 'empty.gif" alt="*" title="" />';
                }
                echo '
					<img id="shout_toggle' . $this->cfg['id'] . '" style="' . ($canEdit ? 'cursor:pointer;' : '') . 'margin-top:6px;float:right;"' . ($canEdit ? ' onclick="ShoutAdmin(' . $this->cfg['id'] . ',\'check\');"' : '') . ' src="' . $Admimg[0] . '" alt="*" title="' . $txt['pmx_shoutbox_toggle'] . '" />
					<input id="shout_key' . $this->cfg['id'] . '" onclick="SendShout(' . $this->cfg['id'] . ', ' . intval(!empty($this->cfg['config']['settings']['boxcollapse'])) . ')" class="button_submit shoutbutton" type="button" name="button" value="' . (!empty($this->cfg['config']['settings']['boxcollapse']) ? $txt['pmx_shoutbox_button_open'] : $txt['pmx_shoutbox_button']) . '" title="' . (!empty($this->cfg['config']['settings']['boxcollapse']) ? $txt['pmx_shoutbox_button_title'] : $txt['pmx_shoutbox_send_title']) . '" />
				</div>
			</div>';
            }
        }
    }