<?php

if($_GET['source'] == "pretty")
{
    
show_source($_SERVER['SCRIPT_FILENAME']);
    exit();
}
elseif(
$_GET['source'] == "plain")
{
    
header("Content-type: text/plain");
    
readfile($_SERVER['SCRIPT_FILENAME']);
    exit();
}

session_start();

require(
'./smarty-libs/Smarty.class.php');
require(
'./libs/SmartyPaginate.class.php');

$smarty =& new Smarty;
$smarty->plugin_dir './plugins';

//SmartyPaginate::disconnect();
SmartyPaginate::connect();
SmartyPaginate::setLimit(10);

$smarty->assign('results'get_db_results());
SmartyPaginate::assign($smarty);
$smarty->display('index.tpl');

function 
get_db_results() {
    
// fabricate 100 items
    
$_data range(1,100);
    
    
SmartyPaginate::setTotal(count($_data));
    
    
// use paginate data to get segment of data
    
return array_slice($_dataSmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
    
}

?>