Location: PHPKode > projects > PHPEcho CMS > kernel/core.inc.php
<?php
/*  +--------------------------------------------
*   |
*   |     Product:       PHPEchoCMS
*   |     Author:        Tigran Abrahamyan
*   |     License:       GPL
*   |     Last updated:  28.03.07
*   |     For version:   2.0 
*   |     Desc:          Core of CMS. Library of Global Functions.
*   |        
*   +--------------------------------------------
*/ 

class core
{
    //-------------------  
    // Initialization of Modules
    //-------------------
    function moduleget()
    {
        global $root_path , $BASE_LOAD , $language , $lang , $smarty, $settings, $core;
        
        $modules = query ( "SELECT * FROM `".PREFIX."modules`" , 1 );
        $mod = query ( "SELECT * FROM `".PREFIX."modules` WHERE `name`='".addslashes(@$_GET['module'])."'", 4);

        if ($mod['status'] == 'OFF' && $mod['show_menu'] == '1') 
	        echo "This module is Disabled!";
        else
        { 
           $i = false;
            
            while( $Module_Check = mysql_fetch_object ($modules) )
            {
                if( @ $_GET['module'] == $Module_Check->name)
                {
                    include ($root_path."modules/".$Module_Check->name."/index.php");
                    $i = true;
                }
            }
            
            if( ! $i )
            {
                include ($root_path."modules/".$this->modname($settings['defaultmodule'])."/index.php"); 
            }
        }
    }

    //-------------------  
    // Initialization of Blocks
    //-------------------
    function blockget ($side)
    {
        global $theme, $root_path, $BASE_LOAD, $smarty, $lang, $core;
        
        $blocks = query("SELECT * FROM `".PREFIX."blocks` WHERE `side` = '$side' ORDER BY `order` ASC", 1);
        $content = "";

        while( $block = mysql_fetch_object ($blocks) )
        {
           if ($block->status == 'ON') 
           { 
	      $content .= "<table width='100%'>";
              if( $block->mysql )
              {
                   $smarty->assign ( "blocktitle" , $block->display_name) ;
                   $smarty->assign ( "blockcontent" , $block->content );
                   $content .= $smarty->fetch ( "block.tpl" );
              }
              elseif ( !$block->mysql )
              {
                   $filename = $root_path."blocks/".$block->name."/index.php";
                   require ($filename);
                   $smarty->assign ( "blocktitle" , $block_display_name) ;
                   $smarty->assign ( "blockcontent" , $block_content );
                   $content .= $smarty->fetch ( "block.tpl" );
              }
              else
              {
                   $content .= "<tr><td>Block error!</td></tr>";
              } 
	      $content .= "</table>";
	    }
        }
        
        echo $content;
    }

    //-------------------  
    // Get micro time
    //-------------------
    function getmicro()
    {
        $result = explode (" ", microtime());
        $result = $result [0] + $result [1];
        return $result;
    }

//-------------------  
// Redirect
//-------------------
function redirect($url)
{
    $content=<<<HTML
    <meta http-equiv="refresh" content="2; url=$url" />
    <script type='text/javascript'>
    //<![CDATA[
    // Fix Mozilla bug: 209020
    location.href = '$url';
    if ( navigator.product == 'Gecko' )
    {
        navstring = navigator.userAgent.toLowerCase();
        geckonum  = navstring.replace( /.*gecko\/(\d+)/, "$1" );
              
        setTimeout("moz_redirect()",1500);
    }
         
    function moz_redirect()
    {
        var url_bit     = "{$url}";
        window.location = url_bit.replace( new RegExp( "&amp;", "g" ) , '&' );
    }
    //>
    </script>
HTML;
    echo $content;
}     

    //-------------------  
    // Get language for module
    //-------------------
    function getlang ($lfile)
    {
        global $root_path, $language, $BASE_LOAD;
        
        include (@$root_path."lang/".$language."/".$lfile.".php");
        
        if ( !isset ( $mlang ) )
        {
            $mlang = "nothing";
        }
        
        return $mlang;
    }

    // Member id to member name convertor
    function mid2mname ($mid)
    {
        $mname = query ("SELECT `username` FROM `".PREFIX."users` WHERE `id` = '".$mid."'", 4);
         
        return $mname['username'];
    }

    // Member name to member id convertor
    function mname2mid($mname)
    {
	$mid = query ("select `id` from `".PREFIX."users` where `username` = '".$mname."'", 4);
	
	return $mid['id'];
    }

    // Module id to module name conv
    function modname($id)
    {
        $module = query ("SELECT `name` FROM `".PREFIX."modules` WHERE `id` = '".$id."'", 4);
        
        return $module['name'];
    }
}
?>
Return current item: PHPEcho CMS