<?

//
//	2002.1.1
//	DICOM to WWW Gateway :PHP script
//	Made by Norya Yokohama % Medical Division @ WERC
//  2004.9.19
//  added by tadashi tsuchimoto @ MITT belong to yokohamazyuku
//  show refered images from database (of cource postgres!)
//


$ruid = $_GET['ruid'];
@$refimage = $_GET['refimage'];



/*

  include "init.inc";
  include "param_setting.ini";
  include "sql_generator.ini";
  include "file_mod.inc";
  $include_path=".";
  require("$include_path/dbconnect.ini");


//DB query

$db = db_contact_start($db_type,$target_host,$target_db);

$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$db->beginTransaction();

$stmt = $db->prepare("select refimage6 from reportlevel where ruid = ?");
$stmt->execute(array($ruid));
$stmt->bindColumn('refimage6', $oid, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);



//$obj = stream_get_contents($db->pgsqlLOBOpen($oid, 'r'));
$obj = $db->pgsqlLOBOpen($oid, 'r');


//mb_http_output();
//header("Content-type: image/jpeg");
//header("Content-Length: " . filesize($obj));



//echo $obj;
fpassthru($obj);

$db->commit();

*/




 $include_path=".";
  require("$include_path/dbconnect_old.ini");

class myDbConnect extends DbConnect {
      var $dbname = "pacsdb";
}

  $con = new myDbConnect;


$result = pg_query("BEGIN");
    pg_locreate();

    header("Content-type: image/jpeg");
    $obj = pg_loopen ($refimage, "rw");
    pg_lo_read_all($obj);

    pg_loclose ($obj);


$result = pg_query("commit");
$result = pg_query("END");

  $con->dbClose;




?>









