Location: PHPKode > projects > mBlog > includes/user_init.php
<?php
// the following syntaxes will be automatically executed EVERYTIME USER INTERFACE (SHOP) ACCESSED
// return current url (url encoded)
function cur_url ()
{
	$script = '';
	if (!empty ($_SERVER['PHP_SELF'])) $script = $_SERVER['PHP_SELF'];					// should be working..
	if (empty ($script) && !empty ($_SERVER['SCRIPT_NAME'])) $script = $_SERVER['SCRIPT_NAME'];	// ..unless in command line
	if (empty ($script) && !empty ($_SERVER['SCRIPT_FILENAME'])) $script = $_SERVER['SCRIPT_FILENAME'];	// IIS & PHP 4.3.0
	if (empty ($script)) die ('Your server is very weird! Contact us now!');				// what the f__?!

	if (empty ($_SERVER["QUERY_STRING"])) $_SERVER["QUERY_STRING"] = "";
	$url = urlencode ("http://".$_SERVER['SERVER_NAME'].$script."?".$_SERVER['QUERY_STRING']);
	return $url;
}


// determine include folder
function get_inc_folder ()
{
	$level2 = array ('admin', 'includes');
	$c = cur_url ();
	if (strpos ($c, 'admin%2F') || strpos ($c, 'includes%2F')) return './..'; else return '.';
}

$inc_folder = get_inc_folder ();
require $inc_folder.'/includes/db_config.php';
require $inc_folder.'/includes/config.php';
require $inc_folder.'/includes/functions.php';
require $inc_folder.'/includes/tpl.php';
require $inc_folder.'/includes/lang.php';
require $inc_folder.'/includes/local.php';
require $inc_folder.'/includes/init.php';

// -- user init start --
// login?
if (isMember ())
{
	$user_login = 1;
	$user_id = $txt['user_id'] = cookie_param ('m_user');
}
else
{
	$user_login = 0;
	$user_id = cookie_param ('m_user');
	$txt['user_id'] = $lang['l_guest'];
}

// develop category list
$txt['category_list'] = '';
foreach ($tmp_tbl as $key => $val)
{
	$row['cat_id'] = $key;
	$row['cat_name'] = $val;
	$txt['category_list'] .= quick_tpl ($tpl_section['cat_list'], $row);
}

// previous blogs
$txt['previous_blog'] = '';
$res = sql_query ("SELECT blog_id, blog_title FROM m_blog ORDER BY blog_date DESC LIMIT 20");
while ($row = sql_fetch_array ($res))
{
	$txt['previous_blog'] .= quick_tpl ($tpl_section['previous'], $row);
}
?>
Return current item: mBlog