<?php 
ini_set("display_errors","1");
ini_set("display_startup_errors","1");
set_magic_quotes_runtime(0);

include("oldinclude/dbcommon.php");
include("oldinclude/##@TABLE.strShortTableName##_variables.php");
##if @BUILDER.arrLanguages.len>1##
include("oldinclude/languages.php");
##endif##

##if @BUILDER.bCreateLoginPage##
if(!@$_SESSION["UserID"] || !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))
{ 
	DisplayCloseWindow(); 
	return;
}
##endif##

$field = @$_GET["field"];
if(!CheckFieldPermissions($field))
	return DisplayCloseWindow();

//	construct sql


$keys=array();
##foreach @TABLE.arrKeyFields as @k##
$keys["##@k s##"]=postvalue("key##@index##");
##endfor##
$where=KeyWhere($keys);

//$sql=$gstrSQL;
//$sql = AddWhere($sql,$where);

$conn=db_connect();

##if @TABLE.nSecOptions==ADVSECURITY_VIEW_OWN  && @BUILDER.nLoginMethod==SECURITY_TABLE && @BUILDER.bCreateLoginPage##
$where=whereAdd($where,SecuritySQL("Search"));
//$sql = AddWhere($sql,SecuritySQL("Search"));
##endif##

$sql = gSQLWhere($where);

$rs = db_query($sql,$conn);
if(!$rs || !($data=db_fetch_array($rs)))
  return DisplayCloseWindow();


$value=nl2br(htmlspecialchars($data[$field]));
echobig($value);
DisplayCloseWindow();
return;


function DisplayCloseWindow()
{
	echo "<br>";
	echo "<hr size=1 noshade>";
	echo "<a href=# onClick='window.close();return false;'>".##message CLOSE_WINDOW##."</a>";
}

?>
