Is URL link from ext system to PacsOne still an option?

Most commonly desired features to be implemented in PacsOne
cwhamilton
Posts:20
Joined:Mon Oct 01, 2012 7:05 pm

Post by cwhamilton » Thu Nov 06, 2014 3:52 pm

The result variable is from applet.php. This is Radscaper's applet.php that I installed at your suggestion.

Code: Select all

	foreach ($uids as $uid) {
		$result = $dbcon->query("SELECT path FROM image where uuid='$uid';");
		$row = $dbcon->fetch_row($result);
		$file = $row[0];
When I run the $result query from the command line it works.

pacsone
Site Admin
Posts:3149
Joined:Tue Sep 30, 2003 2:47 am

Post by pacsone » Fri Nov 07, 2014 4:21 pm

Can you post the content of the applet.php script supplied by Radscaper?

cwhamilton
Posts:20
Joined:Mon Oct 01, 2012 7:05 pm

Post by cwhamilton » Fri Nov 07, 2014 4:37 pm

I'll be glad to, but honestly we're not terribly interested in purchasing Radscaper, I only installed it at your suggestion, because you thought there might be a problem with the risAccess link and the Nagoya viewer. At this point I am just trying to make any link from an external system open an image from PacsOne. I do thank you for your continued assistance.

Radscaper's applet.php file

Code: Select all

<?php
//
// applet.php
//
// Module for displaying images through Radscaper
//
// Modified based on an original version written by Xiaohui Li
//

function appletExists()
{
	$jar = dirname($_SERVER['SCRIPT_FILENAME']) . "/radscaper/radscaper.jar";
	return file_exists($jar);
}

//
// uids - array of SOP instance UIDs to display
//
function appletViewer(&$uids)
{
	$dbcon = new MyConnection();

	print "<APPLET codebase=radscaper/ archive=radscaper.jar code=com.divinev.radscaper.Main.class width=100% height=95%>\n";
	print "<PARAM NAME=Config VALUE=config.xml>\n";
	
	$count = 0;
	foreach ($uids as $uid) {
		$result = $dbcon->query("SELECT path FROM image where uuid='$uid';");
		$row = $dbcon->fetch_row($result);
		$file = $row[0];
		$ls = $file . ".ls";
		$ly = $file . ".ly";
		$rle = $file . ".rle";
		// lossless compression
		if (file_exists($ls) && filesize($ls))
			$file = $ls;
		// lossy compression
		else if (file_exists($ly) && filesize($ly))
			$file = $ly;
		// RLE compression
		else if (file_exists($rle) && filesize($rle))
			$file = $rle;
		printf ("<PARAM NAME=DicomImg%d VALUE=\"%s\">\n", ++$count, $file);
	}
	print "</APPLET>\n";
}

?>

pacsone
Site Admin
Posts:3149
Joined:Tue Sep 30, 2003 2:47 am

Post by pacsone » Sat Nov 08, 2014 9:22 pm

This applet.php script from Radscaper is missing the start of the PHP session at the top of the file, i.e., without it the appletViewer() function won't be able to connect to the PacsOne Server database to retrieve the full path to each raw Dicom image passed to it. So all you need to do is to add the following line at the top of the applet.php script (right below the first comment block):

Code: Select all

session_start();
Save the file then reload the same URL link from your browser. This time, the applet viewer should be able to load all the images as expected.

cwhamilton
Posts:20
Joined:Mon Oct 01, 2012 7:05 pm

Post by cwhamilton » Tue Nov 11, 2014 2:30 pm

I added the session start to the applet.php file so now it looks like this:

Code: Select all

<?php
//
// applet.php
//
// Module for displaying images through Radscaper
//
// Modified based on an original version written by Xiaohui Li
//
session_start();

function appletExists()
{
   $jar = dirname($_SERVER['SCRIPT_FILENAME']) . "/radscaper/radscaper.jar";
   return file_exists($jar);
}

//
// uids - array of SOP instance UIDs to display
//
function appletViewer(&$uids)
{
   $dbcon = new MyConnection();

   print "<APPLET codebase=radscaper/ archive=radscaper.jar code=com.divinev.radscaper.Main.class width=100% height=95%>\n";
   print "<PARAM NAME=Config VALUE=config.xml>\n";
   
   $count = 0;
   foreach ($uids as $uid) {
      $result = $dbcon->query("SELECT path FROM image where uuid='$uid';");
      $row = $dbcon->fetch_row($result);
      $file = $row[0];
      $ls = $file . ".ls";
      $ly = $file . ".ly";
      $rle = $file . ".rle";
      // lossless compression
      if (file_exists($ls) && filesize($ls))
         $file = $ls;
      // lossy compression
      else if (file_exists($ly) && filesize($ly))
         $file = $ly;
      // RLE compression
      else if (file_exists($rle) && filesize($rle))
         $file = $rle;
      printf ("<PARAM NAME=DicomImg%d VALUE=\"%s\">\n", ++$count, $file);
   }
   print "</APPLET>\n";
}

?>
Unfortunately, this did not correct the issue with the external link. Nothing changed, the viewer still works fine through PacsOne, and still fails at the $result query on the external link ($result is not valued).

When I add back in the troubleshooting code to print out the variables, this is what the resulting output looks like when I view source on the browser:

Code: Select all

<html>
<head><title>PacsOne Server - Show Images</title></head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body leftmargin="0" topmargin="0" bgcolor="#cccccc">
<APPLET codebase=radscaper/ archive=radscaper.jar code=com.divinev.radscaper.Main.class width=100% height=95%>
<PARAM NAME=Config VALUE=config.xml>
#0  MyDatabase->fetch_row() called at [C:\Program Files (x86)\PacsOne\php\applet.php:30]
#1  appletViewer(Array ([0] => 1.2.392.200036.9125.4.0.319806482.2051802472.399170569)) called at [C:\Program Files (x86)\PacsOne\php\risAccess2.php:73]
<br>uids array = Array
(
    [0] => 1.2.392.200036.9125.4.0.319806482.2051802472.399170569
)
<br>uid = 1.2.392.200036.9125.4.0.319806482.2051802472.399170569<br>result = <br>row array = <br><br><PARAM NAME=DicomImg1 VALUE="">
</APPLET>
</td></tr><tr><td><HR></td></tr><tr><td><TABLE width=100% border=0 cellpadding=0><TR><TD ALIGN=LEFT><SMALL>PacsOne Server 6.3.8</SMALL></TD><TD ALIGN=CENTER><SMALL>Your current annual technical support option will expire on <u>2015-10-20 10:07:17
 
</u></SMALL><TD ALIGN=RIGHT><SMALL>Copyright 2003-2013 (c) RainbowFish Software</SMALL></TD></TR></TABLE></td></tr></TABLE></body>
</html>
Do the #0 and #1 lines (just under the <PARAM NAME line) indicate an error condition?

Any other suggestions?

pacsone
Site Admin
Posts:3149
Joined:Tue Sep 30, 2003 2:47 am

Post by pacsone » Tue Nov 11, 2014 4:19 pm

Try adding the following line in the php/risdirect.php script:

Code: Select all

// save login information
$_SESSION['authenticatedHost'] = "localhost";
Save the file and reload the same page from your external RIS page and see if you still get the same error or not.

cwhamilton
Posts:20
Joined:Mon Oct 01, 2012 7:05 pm

Post by cwhamilton » Tue Nov 11, 2014 4:36 pm

I added the extra line to the risAcess.php page, but it did not change anything - same results as before. I added the line with the other save login info lines:

Code: Select all

// save login information
$_SESSION['authenticatedDatabase'] = $database;
$_SESSION['authenticatedUser'] = $username;
$_SESSION['authenticatedPassword'] = $password;
$_SESSION['authenticatedHost'] = "localhost";
Thanks again for your help with this issue. I think we are very close to resolving this. I look forward to your next suggestion.

cwhamilton
Posts:20
Joined:Mon Oct 01, 2012 7:05 pm

Post by cwhamilton » Wed Nov 12, 2014 3:50 pm

An interesting find: I added a line in applet.php that prints out the results of $dbcon after $dbcon = new MyConnection();

Code: Select all

function appletViewer(&$uids)
{
	$dbcon = new MyConnection();

    print_r ($dbcon);
	print "<APPLET codebase=radscaper/ archive=radscaper.jar code=com.divinev.radscaper.Main.class width=100% height=95%>\n";
	print "<PARAM NAME=Config VALUE=config.xml>\n";
I checked the differences in the output between using the risAccess.php page and viewing the same image in PacsOne. See below:

Through PacsOne

Code: Select all

MyConnection Object ( [database] => CIA [username] => cw [password] => xxxxxxxx [connection] => mysqli Object ( [affected_rows] => -1 [client_info] => mysqlnd 5.0.8-dev - 20102224 - $Id: 731e5b87ba42146a687c29995d2dfd8b4e40b325 $ [client_version] => 50008 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [field_count] => 0 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.6.15-log [server_version] => 50615 [stat] => Uptime: 3545993 Threads: 4 Questions: 9771406 Slow queries: 0 Opens: 109 Flush tables: 1 Open tables: 102 Queries per second avg: 2.755 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 7356 [warning_count] => 0 ) [useMysql] => 1 [useOracle] => [dbapi] => MysqlAPI Object ( [connection] => mysqli Object ( [affected_rows] => -1 [client_info] => mysqlnd 5.0.8-dev - 20102224 - $Id: 731e5b87ba42146a687c29995d2dfd8b4e40b325 $ [client_version] => 50008 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [field_count] => 0 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.6.15-log [server_version] => 50615 [stat] => Uptime: 3545993 Threads: 4 Questions: 9771407 Slow queries: 0 Opens: 109 Flush tables: 1 Open tables: 102 Queries per second avg: 2.755 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 7356 [warning_count] => 0 ) [useMysqli] => 1 ) [hostname] => localhost ) 
Through risAccess.php

Code: Select all

MyConnection Object ( [database] => CIA [username] => É»][Ñì [password] => ÝSý‰y¾˜© [connection] => [useMysql] => 1 [useOracle] => [dbapi] => MysqlAPI Object ( [connection] => [useMysqli] => 1 ) [hostname] => localhost )
The only edit I made to the output was to "x" out the password in the first $dbcon code block. Does this lead you to believe the credentials aren't getting passed correctly? I hope this information can help steer our next action in getting this resolved. I look forward to your response.

pacsone
Site Admin
Posts:3149
Joined:Tue Sep 30, 2003 2:47 am

Post by pacsone » Wed Nov 12, 2014 10:09 pm

You've just found the source of the problem, where the external risAccess.php script was not encrypting the username/password inforamtion when saving the PHP session data, thus causing the subsequent database queries to fail since the other scripts were all expecting the encrypted username/password from the saved PHP session data.

So the fix is to change the following block of code (after the comment line) in your php/risAccess.php script:

Code: Select all

// save login information
$_SESSION['authenticatedHost'] = "localhost";
$_SESSION['authenticatedDatabase'] = $database;
if (function_exists("mcrypt_module_open")) {    // encrypt username/password
    $key = function_exists("hash")? hash("MD5", session_id()) : session_id();
    setcookie("sessionCookie", $key, time()+7*24*60*60);
    $td = mcrypt_module_open('tripledes', '', 'ecb', '');
    $key = substr($key, 0, mcrypt_enc_get_key_size($td));
    $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
    mcrypt_generic_init($td, $key, $iv);
    $_SESSION['authenticatedUser'] = mcrypt_generic($td, $username);
    $_SESSION['authenticatedPassword'] = mcrypt_generic($td, $password);
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);
} else {
    $_SESSION['authenticatedUser'] = $username;
    $_SESSION['authenticatedPassword'] = $password;
}

cwhamilton
Posts:20
Joined:Mon Oct 01, 2012 7:05 pm

Post by cwhamilton » Thu Nov 13, 2014 3:52 pm

Thank you, thank you, thank you! That little bit of code did the trick! I was able to open images up in Radscaper as well as the Nagoya viewer from my external link!

I really appreciate your persistence and your patience helping me with this issue. And I now know much more about PHP, MySQL and PacsOne!

Post Reply