<?php
if (isset($_GET['function'])){
include 'includes/dbclass.php';
include 'config.php';
require 'libs/Smarty.class.php';
include_once 'includes/geshi.php';
include 'includes/functions.php';
$db = new db($dbhost, $dbuser, $dbpass, $dbname);
$res = $db->query("SELECT proj_name, lang, copyright FROM config");
if (mysql_num_rows($res) == 0)
die("Couldn't get config from database");
$config = mysql_fetch_assoc($res);
$function = sql_quote($_GET['function']);
$func_res = $db->query("SELECT * FROM functions WHERE func_name = '$function'");
if (mysql_num_rows($func_res) == 0)
{
header("Location: index.php"); //couldn't find the function so redirect them back to the homepage
die();
}
$func_info = mysql_fetch_assoc($func_res);
$func_id = $func_info['id'];
$comments_res = $db->query("SELECT * FROM comments WHERE f_id = $func_id");
//format comments
$i = 0;
while ($row = mysql_fetch_assoc($comments_res))
{
$geshi = new GeSHi($row['comment'], $config['lang']);
$geshi->set_header_type(GESHI_HEADER_PRE_VALID);
$comments[$i]['user'] = $row['user'];
$comments[$i]['date'] = date("d-M-Y g:i a", $row['date']);
$comments[$i]['comment'] = $geshi->parse_code();
++$i;
}
$examples_res = $db->query("SELECT * FROM examples WHERE f_id = $func_id");
$i = 0;
if (mysql_num_rows($examples_res) > 0 )
while ($row = mysql_fetch_assoc($examples_res))
{
$geshi = new GeSHi($row['code_example'], $config['lang']);
$examples[$i]['code'] = $geshi->parse_code();
$examples[$i]['desc'] = $row['example_desc'];
$examples[$i]['notes'] = $row['example_notes'];
++$i;
}
$i = 0;
$parameters_res = $db->query("SELECT * FROM parameters WHERE f_id = $func_id");
if (mysql_num_rows($parameters_res) > 0) {
while ($row = mysql_fetch_assoc($parameters_res))
{
$parameters[$i]['name'] = $row['param_name'];
$parameters[$i]['desc'] = $row['param_desc'];
$parameters[$i]['type'] = $row['type'];
++$i;
}
} else {
$parameters[0]['name'] = "None";
}
$smarty = new Smarty;
$smarty->compile_check = true;
//$smarty->force_compile = true;
/*if ($_GET['modrewrite'] == 1){
$headers = '<script type="text/javascript" src="../../js/prototype.js"></script>
<script type="text/javascript" src="../../js/processcomment.js"></script>
<script type="text/javascript" src="../../js/base64.js"></script>
<link rel="stylesheet" href="../../css/css.css"/>
';
} else {*/ //future use
$headers = '<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/processcomment.js"></script>
<script type="text/javascript" src="js/base64.js"></script>
<link rel="stylesheet" href="css/css.css"/>
';
//}
$smarty->assign("project", $config['proj_name']);
$smarty->assign("copyright", $config['copyright']);
$smarty->assign("last_update", date("D, d M Y", $func_info['last_update']));
$smarty->assign("function", $func_info['func_name']);
$smarty->assign("descrption", $func_info['short_desc']);
$smarty->assign("ret_type", $func_info['ret_type']);
$smarty->assign("notes", nl2br($func_info['notes']));
$smarty->assign("version_info", $func_info['version_info']);
$smarty->assign("ret_desc", $func_info['ret_desc']);
$smarty->assign("ret_values", $func_info['ret_values']);
$smarty->assign("function", $function);
$smarty->assign("comments", $comments);
$smarty->assign("examples", $examples);
$smarty->assign("para_desc", $parameters);
$smarty->assign("headers", $headers);
$smarty->assign("logo", "images/logo2.gif");
//$smarty->assign("function", "echo");
//$smarty->assign("descrption", "output some stuff to the screenz");
$smarty->display('code.tpl');
} else {
header("Location: index.php");
}
?>