Location: PHPKode > scripts > Kemana Directory > module/portal/read.php
<?php
//
$page_id = get_param ('pid');
$p = get_param ('p');

if (empty ($page_id)) redir ($config['site_url']);

// load content
$sub_page = TRUE;
$tpl = load_tpl ('mod', 'module_portal_read.tpl');
$res = sql_query ("SELECT * FROM ".$db_prefix."ppage WHERE page_id = '$page_id' LIMIT 1");
$row = sql_fetch_array ($res);

// pagebreak
$foo = explode ('<!--pagebreak-->', $row['page_body']);
if (empty ($p)) $p = 1;
$row['page_body'] = $foo[$p-1];
$row['pagination'] = generate_pagination ("page.php?pid=$page_id", count($foo), $p, 1);	 

// image gallery
$i = 0; $ok = FALSE;
$row['block_thumb'] = '';
while (!$ok)
{
	$i++;
	$foo = array ();
	$fn = 'page_img_'.$page_id.'_'.$i;
	$folder = 'public/image';
	if (file_exists ($folder.'/'.$fn.'.jpg'))
	{
		// use make_thumb ($fn, 'gallery', '', $i) => to show only pic #1
		$foo['image'] = $fn.'.jpg';
		$row['block_thumb'] .= quick_tpl ($tpl_block['thumb'], $foo);
	}
	else
		$ok = TRUE;
}

// also-pages list
$row['block_list'] = '';
$res2 = sql_query ("SELECT page_id, page_title, page_summary FROM ".$db_prefix."ppage WHERE cat_id = '$row[cat_id]' ORDER BY page_id DESC LIMIT 5");
while ($row2 = sql_fetch_array ($res2)) $row['block_list'] .= quick_tpl ($tpl_block['list'], $row2);

if (!empty ($row['block_list'])) $sub_page = TRUE; else $sub_page = FALSE;

// update hit
sql_query ("UPDATE ".$db_prefix."ppage SET page_hit=page_hit+1 WHERE page_id = '$page_id' LIMIT 1");

$row['cat_name'] = pcat_name ($row['cat_id'], FALSE);
$row['where_am_i'] = pcat_name ($row['cat_id'], TRUE, TRUE);
$txt['main_body'] = quick_tpl (load_tpl ('mod', 'module_portal_read.tpl'), $row);	// reload page.tpl
generate_html_header ($config['site_name'].' '.$config['cat_separator'].' '.strip_tags ($row['where_am_i']).$config['cat_separator'].' '.$row['page_title']);
flush_tpl ();
?>
Return current item: Kemana Directory