Exemplo n.º 1
0
/**
 * Gets the content of necessary widget's application.
 * @param sModule - module(widget) name.
 * @param sApp - application name in the widget.
 * @param aParamValues - an associative array of parameters to be passed into the Flash object.
 * @param bInline - whether you want to have it with the full page code(for opening in a new window)
 * or only DIV with flash object (for embedding into the existing page).
 */
function getApplicationContent($sModule, $sApp, $aParamValues = array(), $bInline = false, $bEmbedCode = false, $sHtmlId = "")
{
    global $sGlobalUrl;
    global $sHomeUrl;
    global $sRayHomeDir;
    global $sModulesUrl;
    global $sModulesPath;
    global $sFlashPlayerVersion;
    $sModule = isset($sModule) ? $sModule : process_db_input($_REQUEST['module']);
    $sApp = isset($sApp) ? $sApp : process_db_input($_REQUEST['app']);
    $sModuleStatus = getSettingValue($sModule, "status", "main");
    if ($sModuleStatus == WIDGET_STATUS_NOT_INSTALLED || $sModuleStatus == WIDGET_STATUS_DISABLED) {
        return "";
    }
    $aConfig = getFlashConfig($sModule, $sApp, $aParamValues);
    $aModules = $aConfig['modules'];
    if (!isset($bInline)) {
        $bInline = $aModules[$sApp]['inline'];
    }
    //--- Parameters for container's div ---//
    $sDivId = !empty($aModules[$sApp]['div']['id']) ? $aModules[$sApp]['div']['id'] : '';
    if (!empty($sHtmlId)) {
        $sDivId = $sHtmlId;
    }
    if (empty($sDivId)) {
        $sDivId = $sModule . '_' . $sApp;
    }
    $sInnerDivId = $sDivId . "_" . time();
    if (empty($sHtmlId)) {
        $sHtmlId = "ray_" . $sModule . "_" . $sApp . "_object";
    }
    $sDivName = !empty($aModules[$sApp]['div']['name']) ? ' name="' . $aModules[$sApp]['div']['name'] . '"' : '';
    if (!empty($aModules[$sApp]['div']['style'])) {
        $sDivStyle = ' style="';
        foreach ($aModules[$sApp]['div']['style'] as $sKey => $sValue) {
            $sDivStyle .= $sKey . ':' . $sValue . ';';
        }
        $sDivStyle .= '"';
    } else {
        $sDivStyle = '';
    }
    //--- Parameters for SWF object and reloading ---//
    $aParametersReload = array();
    if (!isset($_GET["module"])) {
        $aParametersReload[] = "module=" . $sModule;
    }
    if (!isset($_GET["app"])) {
        $aParametersReload[] = "app=" . $sApp;
    }
    ob_start();
    if (!$bInline) {
        ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
        <head>
            <title><?php 
        echo $aModules[$sApp]['caption'];
        ?>
</title>
            <meta http-equiv=Content-Type content="text/html;charset=UTF-8" />
        </head>
        <body style="margin:0; padding:0;"  <?php 
        echo $aModules[$sApp]['hResizable'] || $aModules[$sApp]['vResizable'] ? 'onLoad="resizeWindow()" onResize="if ( window.resizeWindow ) resizeWindow()"' : '';
        ?>
 >
<?php 
        echo getRayIntegrationJS();
    }
    if (!$bEmbedCode) {
        foreach ($aModules[$sApp]['js'] as $sJSUrl) {
            echo "\t\t<script src=\"" . $sJSUrl . "\" type=\"text/javascript\" language=\"javascript\"></script>\n";
        }
    }
    if (!$bEmbedCode && ($aModules[$sApp]['hResizable'] || $aModules[$sApp]['vResizable'])) {
        $iMinWidth = (int) $aModules[$sApp]['minSize']['width'];
        $iMinHeight = (int) $aModules[$sApp]['minSize']['height'];
        ?>
    <script type="text/javascript" language="javascript">
        function resizeWindow()
        {
            var frameWidth = 0;
            var frameHeight = 0;

            if (document.documentElement) {
                if(document.documentElement.clientHeight) {
                    frameWidth = document.documentElement.clientWidth;
                    frameHeight = document.documentElement.clientHeight;
                }
            } else if(window.innerWidth) {
                frameWidth = window.innerWidth;
                frameHeight = window.innerHeight;
            } else if (document.body) {
                frameWidth = document.body.offsetWidth;
                frameHeight = document.body.offsetHeight;
            }

            var sAppName = 'ray_flash_<?php 
        echo $sModule;
        ?>
_<?php 
        echo $sApp;
        ?>
_';
            var o = document.getElementById(sAppName + 'object');
            var e = document.getElementById(sAppName + 'embed');

            frameWidth = (frameWidth < <?php 
        echo $iMinWidth;
        ?>
) ? <?php 
        echo $iMinWidth;
        ?>
 : frameWidth;
            frameHeight = (frameHeight < <?php 
        echo $iMinHeight;
        ?>
) ? <?php 
        echo $iMinHeight;
        ?>
 : frameHeight;

<?php 
        $sRet = $aModules[$sApp]['hResizable'] ? "o.width = frameWidth;\n" : "";
        $sRet .= $aModules[$sApp]['vResizable'] ? "o.height = frameHeight;\n" : "";
        $sRet .= "if(e != null){";
        $sRet .= $aModules[$sApp]['hResizable'] ? "e.width = frameWidth;\n" : "";
        $sRet .= $aModules[$sApp]['vResizable'] ? "e.height = frameHeight;\n" : "";
        $sRet .= "}";
        echo $sRet;
        ?>
        }
    </script>
<?php 
    }
    if (!$bEmbedCode && $aModules[$sApp]['reloadable']) {
        if (!$bInline) {
            echo getRedirectForm($sModule, $sApp, array_merge($_GET, $_POST));
        }
        ?>
    <script type="text/javascript" language="javascript">
        function reload()
        {
<?php 
        $sGet = $_SERVER['QUERY_STRING'];
        $sExtraGet = implode("&", $aParametersReload);
        if (!empty($sGet) && !empty($sExtraGet)) {
            $sGet .= "&";
        }
        echo !$bInline ? "redirect();" : "location.href='" . $_SERVER['PHP_SELF'] . "?" . $sGet . $sExtraGet . "';";
        ?>
        }
    </script>
<?php 
    }
    ?>
<div id="<?php 
    echo $sDivId;
    ?>
" <?php 
    echo $sDivName . $sDivStyle;
    ?>
><div id="<?php 
    echo $sInnerDivId;
    ?>
"></div></div>
<script type="text/javascript" language="javascript">
<?php 
    foreach ($aConfig['flashVars'] as $sKey => $sValue) {
        if (!isset($_GET[$sKey]) && $sKey != 'url') {
            $aParametersReload[] = $sKey . "=" . (isset($aConfig['flashVars'][$sKey]) ? $aConfig['flashVars'][$sKey] : process_db_input($_REQUEST[$sKey]));
        }
    }
    echo phpArrayToJS($aConfig['flashVars'], "flashvars");
    echo phpArrayToJS($aConfig['params'], "params");
    ?>

var attributes = {
    id: "ray_flash_<?php 
    echo $sModule;
    ?>
_<?php 
    echo $sApp;
    ?>
_object",
    name: "ray_flash_<?php 
    echo $sModule;
    ?>
_<?php 
    echo $sApp;
    ?>
_embed",
    style: "display:block;"
};
swfobject.embedSWF("<?php 
    echo $aConfig['holder'];
    ?>
", "<?php 
    echo $sInnerDivId;
    ?>
", "<?php 
    echo $aConfig['width'];
    ?>
", "<?php 
    echo $aConfig['height'];
    ?>
", "<?php 
    echo $sFlashPlayerVersion;
    ?>
", "<?php 
    echo $sGlobalUrl;
    ?>
app/expressInstall.swf", flashvars, params, attributes);
</script>
<?php 
    if (!$bInline) {
        ?>
        </body>
    </html>
<?php 
    }
    $sWidgetContent = ob_get_contents();
    ob_end_clean();
    return $sWidgetContent;
}
/**
 * Gets the content of necessary widget's application.
 * @param sModule - module(widget) name.
 * @param sApp - application name in the widget.
 * @param aParamValues - an associative array of parameters to be passed into the Flash object.
 * @param bInline - whether you want to have it with the full page code(for opening in a new window)
 * or only DIV with flash object (for embedding into the existing page).
 */
function getApplicationContent($sModule, $sApp, $aParamValues = array(), $bInline = false, $bEmbedCode = false)
{
    global $sGlobalUrl;
    global $sHomeUrl;
    global $sRayHomeDir;
    global $sModulesUrl;
    global $sModulesPath;
    $sModule = isset($sModule) ? $sModule : $_REQUEST['module'];
    $sApp = isset($sApp) ? $sApp : $_REQUEST['app'];
    $sModuleStatus = getSettingValue($sModule, "status", "main");
    if ($sModuleStatus == WIDGET_STATUS_NOT_INSTALLED || $sModuleStatus == WIDGET_STATUS_DISABLED) {
        return "";
    }
    if (isset($aModules)) {
        unset($aModules);
    }
    require $sModulesPath . $sModule . "/inc/header.inc.php";
    require $sModulesPath . $sModule . "/inc/constants.inc.php";
    //--- Print container ---//
    $sRayAppBaseDir = $sModulesUrl . $sModule . "/";
    $sRayHolderBaseDir = $sModulesUrl . "global/";
    if (!isset($bInline)) {
        $bInline = $aModules[$sApp]['inline'];
    }
    $iWidth = getSettingValue($sModule, $sApp . "_width");
    if (empty($iWidth)) {
        $iWidth = $aModules[$sApp]['layout']['width'];
    }
    $iHeight = getSettingValue($sModule, $sApp . "_height");
    if (empty($iHeight)) {
        $iHeight = $aModules[$sApp]['layout']['height'];
    }
    //--- Parameters for container's div ---//
    $sDivId = !empty($aModules[$sApp]['div']['id']) ? ' id="' . $aModules[$sApp]['div']['id'] . '"' : '';
    $sDivName = !empty($aModules[$sApp]['div']['name']) ? ' name="' . $aModules[$sApp]['div']['name'] . '"' : '';
    if (count($aModules[$sApp]['div']['style'])) {
        $sDivStyle = ' style="';
        foreach ($aModules[$sApp]['div']['style'] as $sKey => $sValue) {
            $sDivStyle .= $sKey . ':' . $sValue . ';';
        }
        $sDivStyle .= '"';
    } else {
        $sDivStyle = '';
    }
    //--- Parameters for SWF object and reloading ---//
    $aParametersReload = array();
    if (!isset($_GET["module"])) {
        $aParametersReload[] = "module=" . $sModule;
    }
    if (!isset($_GET["app"])) {
        $aParametersReload[] = "app=" . $sApp;
    }
    $sParameters = "module=" . $sModule . "&amp;app=" . $sApp;
    foreach ($aModules[$sApp]['parameters'] as $sParameter) {
        $sParameters .= "&amp;" . $sParameter . "=" . (isset($aParamValues[$sParameter]) ? $aParamValues[$sParameter] : $_REQUEST[$sParameter]);
        if (!isset($_GET[$sParameter])) {
            $aParametersReload[] = $sParameter . "=" . (isset($aParamValues[$sParameter]) ? $aParamValues[$sParameter] : $_REQUEST[$sParameter]);
        }
    }
    $sParameters .= "&amp;url=" . $sHomeUrl . "XML.php";
    switch ($aInfo['mode']) {
        case 'as3':
            $sHolder = "holder_as3.swf";
            break;
        case 'paid':
            $sHolder = "holder.swf";
            break;
        case 'free':
        default:
            $sHolder = "holder_free.swf";
            break;
    }
    if (isset($aModules[$sApp]['holder'])) {
        $sHolder = $aModules[$sApp]['holder'] . ".swf";
    }
    ob_start();
    if (!$bInline) {
        ?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html>
		<head>
			<title><?php 
        echo $aModules[$sApp]['caption'];
        ?>
</title>
			<meta http-equiv=Content-Type content="text/html;charset=UTF-8" />
		</head>
		<body style="margin:0; padding:0;"  <?php 
        echo $aModules[$sApp]['hResizable'] || $aModules[$sApp]['vResizable'] ? 'onLoad="resizeWindow()" onResize="if ( window.resizeWindow ) resizeWindow()"' : '';
        ?>
 >
<?php 
        echo getRayIntegrationJS();
    }
    if (!$bEmbedCode) {
        foreach ($aModules[$sApp]['js'] as $sJSUrl) {
            echo "\t\t<script src=\"" . $sJSUrl . "\" type=\"text/javascript\" language=\"javascript\"></script>\n";
        }
    }
    if (!$bEmbedCode && ($aModules[$sApp]['hResizable'] || $aModules[$sApp]['vResizable'])) {
        $iMinWidth = (int) $aModules[$sApp]['minSize']['width'];
        $iMinHeight = (int) $aModules[$sApp]['minSize']['height'];
        ?>
	<script type="text/javascript" language="javascript">
	<!--
		function resizeWindow()
		{
			var frameWidth = 0;
			var frameHeight = 0;
				
			if(window.innerWidth)
			{
				frameWidth = window.innerWidth;
				frameHeight = window.innerHeight;
			}
			else if (document.documentElement)
			{
				if(document.documentElement.clientHeight)
				{
					frameWidth = document.documentElement.clientWidth;
					frameHeight = document.documentElement.clientHeight;
				}
			}
			else if (document.body)
			{
				frameWidth = document.body.offsetWidth;
				frameHeight = document.body.offsetHeight;
			}
				
			var o = document.getElementById('ray_<?php 
        echo $sApp;
        ?>
_object');
			var e = document.getElementById('ray_<?php 
        echo $sApp;
        ?>
_embed');
				
			frameWidth = (frameWidth < <?php 
        echo $iMinWidth;
        ?>
) ? <?php 
        echo $iMinWidth;
        ?>
 : frameWidth;
			frameHeight = (frameHeight < <?php 
        echo $iMinHeight;
        ?>
) ? <?php 
        echo $iMinHeight;
        ?>
 : frameHeight;
				
<?php 
        $sRet = $aModules[$sApp]['hResizable'] ? "o.width = frameWidth;\n" : "";
        $sRet .= $aModules[$sApp]['vResizable'] ? "o.height = frameHeight;\n" : "";
        $sRet .= "if(e != null){";
        $sRet .= $aModules[$sApp]['hResizable'] ? "e.width = frameWidth;\n" : "";
        $sRet .= $aModules[$sApp]['vResizable'] ? "e.height = frameHeight;\n" : "";
        $sRet .= "}";
        echo $sRet;
        ?>
		}
	-->
	</script>
<?php 
    }
    if (!$bEmbedCode && $aModules[$sApp]['reloadable']) {
        if (!$bInline) {
            echo getRedirectForm($sModule, $sApp, array_merge($_GET, $_POST));
        }
        ?>
	<script type="text/javascript" language="javascript">
	<!--
		function reload()
		{
<?php 
        $sGet = $_SERVER['QUERY_STRING'];
        $sExtraGet = implode("&", $aParametersReload);
        if (!empty($sGet) && !empty($sExtraGet)) {
            $sGet .= "&";
        }
        echo !$bInline ? "redirect();" : "location.href='" . $_SERVER['PHP_SELF'] . "?" . $sGet . $sExtraGet . "';";
        ?>
		}
	-->
	</script>
<?php 
    }
    ?>
<div<?php 
    echo $sDivId . $sDivName . $sDivStyle;
    ?>
><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" <?php 
    echo 'width="' . $iWidth . '" height="' . $iHeight . '"';
    ?>
 id="ray_<?php 
    echo $sApp;
    ?>
_object" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="<?php 
    echo $sRayHolderBaseDir . "app/" . $sHolder;
    ?>
" /><param name="quality" value="high" /><param name="allowFullScreen" value="true" /><param name="base" value="<?php 
    echo $sRayAppBaseDir;
    ?>
" /><param name="FlashVars" value="<?php 
    echo $sParameters;
    ?>
" /><embed id="ray_<?php 
    echo $sApp;
    ?>
_embed"	name="ray_<?php 
    echo $sApp;
    ?>
"	src="<?php 
    echo $sRayHolderBaseDir . "app/" . $sHolder;
    ?>
" quality="high" allowFullScreen="true" <?php 
    echo 'width="' . $iWidth . '" height="' . $iHeight . '"';
    ?>
 align="middle" allowScriptAccess="always" base="<?php 
    echo $sRayAppBaseDir;
    ?>
" FlashVars="<?php 
    echo $sParameters;
    ?>
" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>
<?php 
    /*	if(!$bEmbedCode)
    	{
    ?>
    	<script type="text/javascript" language="javascript">
    	<!--
    		theObjects = document.getElementsByTagName("object");
    		for (var i = 0; i < theObjects.length; i++) 
    			theObjects[i].outerHTML = theObjects[i].outerHTML;
    	-->
    	</script>
    <?
    	}*/
    if (!$bInline) {
        ?>
		</body>
	</html>
<?php 
    }
    $sWidgetContent = ob_get_contents();
    ob_end_clean();
    return $sWidgetContent;
}
    function TmplKeysReplace($m)
    {
        global $site;
        global $dir;
        global $logged;
        global $aPageContCache;
        global $_page_cont;
        global $oTemplConfig;
        global $_page;
        global $oTemplConfig;
        if (!isset($aPageContCache)) {
            $aPageContCache = array();
        }
        //if already generated it, return it.
        if (isset($aPageContCache[$m[1]])) {
            return $aPageContCache[$m[1]];
        }
        //if it already exists, return it
        if (isset($_page_cont[0]) and array_key_exists($m[1], $_page_cont[0])) {
            return $_page_cont[0][$m[1]];
        }
        $ni = $_page['name_index'];
        //if page generated it, return it
        if ($ni and isset($_page_cont[$ni]) and array_key_exists($m[1], $_page_cont[$ni])) {
            return $_page_cont[$ni][$m[1]];
        }
        //echoDbg( $m );
        $sRet = '';
        // now switch what we have
        switch ($m[1]) {
            case 'page_charset':
                $sRet = 'UTF-8';
                break;
                // it will be removed soon
            // it will be removed soon
            case 'site_url':
                $sRet = $site['url'];
                break;
            case 'plugins':
                $sRet = $site['plugins'];
                break;
            case 'images':
                $sRet = $site['images'];
                break;
            case 'css_dir':
                $sRet = $site['css_dir'];
                break;
            case 'icons':
                $sRet = $site['icons'];
                break;
            case 'zodiac':
                $sRet = $site['zodiac'];
                break;
            case 'switch_lang_block':
                $sRet = getLangSwitcher();
                break;
            case 'main_logo':
                $sRet = getMainLogo();
                break;
            case 'hello_member':
                $sRet = HelloMemberSection();
                break;
            case 'thumb_width':
                $sRet = getParam('max_thumb_width');
                break;
            case 'thumb_height':
                $sRet = getParam('max_thumb_height');
                break;
            case 'main_div_width':
                $sRet = getParam('main_div_width');
                break;
            case 'switch_skin_block':
                $sRet = getParam("enable_template") ? templates_select_txt() : '';
                break;
            case 'meta_keywords':
                $sRet = process_line_output(getParam("MetaKeyWords"));
                break;
            case 'meta_description':
                $sRet = process_line_output(getParam("MetaDescription"));
                break;
            case 'top_menu':
                $oMenu = new BxTemplMenu();
                $sRet = $oMenu->getCode();
                break;
            case 'extra_js':
                $sRet = $_page['extra_js'];
                break;
            case 'extra_css':
                $sRet = $_page['extra_css'];
                break;
            case 'page_header':
                $sRet = $_page['header'];
                break;
            case 'page_header_text':
                $sRet = $_page['header_text'];
                break;
            case 'banner_top':
                $sRet = banner_put_nv(1);
                break;
            case 'banner_left':
                $sRet = banner_put_nv(2);
                break;
            case 'banner_right':
                $sRet = banner_put_nv(3);
                break;
            case 'banner_bottom':
                $sRet = banner_put_nv(4);
                break;
            case 'bottom_text':
                $sRet = _t('_bottom_text', date('Y'));
                break;
            case 'copyright':
                $sRet = _t('_copyright', date('Y')) . getVersionComment();
                break;
                // please do not delete version for debug possibilities
                //Path to css
            // please do not delete version for debug possibilities
            //Path to css
            case 'styles':
                if (strlen($_page['css_name'])) {
                    $sFile = $dir['root'] . $site['css_dir'] . $_page['css_name'];
                    if (file_exists($sFile) && is_file($sFile)) {
                        $sRet = '
							<link href="' . $site['url'] . $site['css_dir'] . $_page['css_name'] . '" rel="stylesheet" type="text/css" />';
                    }
                }
                break;
                //Path to js
            //Path to js
            case 'java_script':
                if (strlen($_page['js_name'])) {
                    $sFile = $dir['root'] . 'inc/js/' . $_page['js_name'];
                    if (file_exists($sFile) && is_file($sFile)) {
                        $langDelete = _t('_delete');
                        $langLoading = _t('_loading ...');
                        $langDeleteMessage = _t('_poll successfully deleted');
                        $langMakeIt = _t('_make it');
                        $lang_you_should_specify_member = _t('_You should specify at least one member');
                        if ($site['js_init']) {
                            $sRet = $site['js_init'];
                        }
                        $sRet .= <<<EOJ
\t<script type="text/javascript" language="javascript">
\t\t\t\t\tvar site_url = '{$site['url']}';
\t\t\t\t\tvar lang_delete = '{$langDelete}';
\t\t\t\t\tvar lang_loading = '{$langLoading}';
\t\t\t\t\tvar lang_delete_message = '{$langDeleteMessage}';
\t\t\t\t\tvar lang_make_it = '{$langMakeIt}';
\t\t\t\t\tvar lang_you_should_specify_member = '{$lang_you_should_specify_member}';
\t\t\t\t\t
\t\t\t\t\tvar iQSearchWindowWidth  = {$oTemplConfig->iQSearchWindowWidth};
\t\t\t\t\tvar iQSearchWindowHeight = {$oTemplConfig->iQSearchWindowHeight};
\t</script>
\t<script src="{$site['url']}inc/js/{$_page['js_name']}" type="text/javascript" language="javascript"></script>
EOJ;
                    }
                }
                break;
                //--- Ray IM Integration ---//
            //--- Ray IM Integration ---//
            case 'ray_invite_js':
                $sRet = getRayIntegrationJS();
                break;
            case 'ray_invite_swf':
                if ($logged['member']) {
                    $iId = (int) $_COOKIE['memberID'];
                    $sPassword = getPassword($iId);
                    $bEnableRay = getParam('enable_ray');
                    $aCheckRes = checkAction($iId, ACTION_ID_USE_RAY_IM);
                    if ($bEnableRay && $aCheckRes[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED) {
                        $sRet = getApplicationContent('im', 'invite', array('id' => $iId, 'password' => $sPassword), true);
                    }
                }
                break;
                //--- Ray IM Integration ---//
            //--- Ray IM Integration ---//
            default:
                if (substr($m[1], 0, 4) == 'TOP_' or substr($m[1], 0, 4) == 'BMI_') {
                    // insert top and bottom links
                    global $aMainLinks;
                    $sPre = substr($m[1], 0, 4);
                    $sLinkName = substr($m[1], 4);
                    if (isset($aMainLinks[$sLinkName])) {
                        $aLink = $aMainLinks[$sLinkName];
                        $bShow = true;
                        if (isset($aLink['Check'])) {
                            $sFunc = create_function('', $aLink['Check']);
                            $bShow = $sFunc();
                        }
                        if ($bShow) {
                            $sClass = $sPre == 'TOP_' ? 'menu_item_link' : 'bottommenu';
                            $sOnclick = isset($aLink['onclick']) ? 'onclick="' . $aLink['onclick'] . '"' : '';
                            $sTitle = _t($aLink['Title']);
                            $sRet = <<<BLAH
\t\t\t\t\t\t\t\t<a href="{$site['url']}{$aLink['href']}" class="{$sClass}" {$sOnclick}>{$sTitle}</a>
BLAH;
                        }
                    } else {
                        $sRet = $m[0];
                    }
                    //return found string back
                } elseif (($sTemplAdd = TemplPageAddComponent($m[1])) !== false) {
                    $sRet = $sTemplAdd;
                } else {
                    $sRet = $m[0];
                }
                //return found string back
        }
        $aPageContCache[$m[1]] = $sRet;
        return $sRet;
    }
function TopCodeAdmin($extraCodeInBody = '')
{
    global $dir;
    global $site;
    global $admin_dir;
    global $_page;
    global $logged;
    global $sRayHomeDir;
    if ($logged['admin']) {
        $logo_alt = 'Admin';
        $user = '******';
    } elseif ($logged['aff']) {
        $logo_alt = 'Affiliate';
        $user = '******';
    } elseif ($logged['moderator']) {
        $logo_alt = 'Moderator';
        $user = '******';
    }
    $selfCateg = 0;
    $selfCategIcon = '';
    $self = basename($_SERVER['PHP_SELF']);
    if ($self != 'index.php') {
        $aSelfCateg = db_assoc_arr("\r\n\t\t\tSELECT\r\n\t\t\t\t`Categ`,\r\n\t\t\t\t`AdminMenuCateg`.`Icon`\r\n\t\t\tFROM `AdminMenu`\r\n\t\t\tLEFT JOIN `AdminMenuCateg` ON\r\n\t\t\t\t`AdminMenuCateg`.`ID` = `AdminMenu`.`Categ`\r\n\t\t\tWHERE\r\n\t\t\t\tRIGHT(`Url`, " . strlen($self) . ")='{$self}' AND\r\n\t\t\t\t`User`='{$user}'\r\n\t\t\t");
        $selfCateg = (int) $aSelfCateg['Categ'];
        $selfCategIcon = $aSelfCateg['Icon'];
    } else {
        $admin_categ = (int) $_GET['admin_categ'];
        if ($admin_categ) {
            $aSelfCateg = db_assoc_arr("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\t`ID`,\r\n\t\t\t\t\t`Title`,\r\n\t\t\t\t\t`Icon`\r\n\t\t\t\tFROM `AdminMenuCateg`\r\n\t\t\t\tWHERE\r\n\t\t\t\t\t`ID`={$admin_categ} AND\r\n\t\t\t\t\t`User`='{$user}'\r\n\t\t\t\t");
            if ($aSelfCateg) {
                $selfCateg = (int) $aSelfCateg['ID'];
                $selfCategIcon = $aSelfCateg['Icon'];
                $_page['header'] = $aSelfCateg['Title'];
            }
        }
    }
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
	<head>
		<title>Admin panel: <?php 
    echo $_page['header'];
    ?>
 </title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="<?php 
    echo $site['plugins'];
    ?>
calendar/calendar_themes/aqua.css" type="text/css" />
		<link href="<?php 
    echo $site['url_admin'];
    ?>
styles/general.css" rel="stylesheet" type="text/css" />
<?php 
    if (strlen($_page['css_name']) and file_exists("{$dir['root']}{$admin_dir}/styles/{$_page['css_name']}")) {
        ?>
		<link href="styles/<?php 
        echo $_page['css_name'];
        ?>
" rel="stylesheet" type="text/css" />
		<link href="styles/<?php 
        echo $_page['css_name2'];
        ?>
" rel="stylesheet" type="text/css" />
	<?php 
    }
    ?>

		<?php 
    echo getRayIntegrationJS();
    ?>

		<script src="<?php 
    echo $site['url'];
    ?>
inc/js/functions.js" type="text/javascript" language="javascript"></script>
		<script src="<?php 
    echo $site['url'];
    ?>
plugins/jquery/jquery.js" type="text/javascript" language="javascript"></script>
		
		<!--[if lt IE 7.]>
		<script defer type="text/javascript">
			var site_url = '<?php 
    echo $site['url'];
    ?>
';
		</script>
		<script defer type="text/javascript" src="../inc/js/pngfix.js"></script>
		<![endif]-->
		
<?php 
    if (strlen($_page['js_name'])) {
        echo <<<EOJ
<script type="text/javascript">
<!--
\tvar site_url = '{$site['url']}';
\tvar lang_delete = 'delete';
\tvar lang_loading = 'loading ...';
\tvar lang_delete_message = 'Poll successfully deleted';
\tvar lang_make_it = 'make it';
-->
</script>
<script src="{$site['url']}inc/js/{$_page['js_name']}" type="text/javascript" language="javascript"></script>
EOJ;
    }
    ?>
		<?php 
    echo $_page['extraCodeInHead'];
    ?>
	</head>
	<body id="admin_cont">
		<div id="FloatDesc"></div>
		<?php 
    echo $_page['extraCodeInBody'];
    ?>
		<?php 
    echo $extraCodeInBody;
    ?>
	
	<?php 
    if ($logged['admin'] || $logged['aff'] || $logged['moderator']) {
        ?>
		<div class="top_header">
			
			<img src="<?php 
        echo $site['url_admin'];
        ?>
images/top_dol_logo.png" class="top_logo" />
			<div class="top_head_title">
				<span class="head_blue">
					<span class="title_bold">Dolphin</span> <?php 
        echo $logo_alt;
        ?>
 -
				</span>
				<?php 
        echo $site['title'];
        ?>
			</div>
			
			<div class="boonex_link">
				<a href="http://www.boonex.com/" title="BoonEx - Community Software Experts">
					<img src="<?php 
        echo $site['url_admin'];
        ?>
images/boonex.png" alt="BoonEx - Community Software Experts" />
				</a>
			</div>
			
		</div>

		<table class="middle_wrapper">
			<tr>
				<td class="right_menu_wrapper">
					<div class="clear_both"></div>
						<?php 
        echo getAdminMenu();
        ?>
					<div class="clear_both"></div>
					<div style="text-align:center; margin:20px;">
						<a href="http://www.boonex.com/unity/" title="Unity - Global Community">
							<img src="<?php 
        echo $site['url_admin'];
        ?>
images/unity_logo.jpg" alt="Unity - Global Community" />
						</a>
					</div>
					<div style="width:10px;height:200px;"></div>
				</td>
				
				<td class="main_cont" id="main_cont">
					<div class="page_header"><?php 
        echo $_page['header'];
        ?>
</div>
					
					<div class="page_cont">
		<?php 
    }
}