PHP wrapper to customize output

  • I created a php wrapper to grab the web output from dgate.exe so I could manipulate the web page look and feel and possibly add some security later like a login. As long as dgate.exe html output stays pretty static like it is this should work (will have to replace the head/title removal line depending on version). This was created using PHP 5.2 but it might work with PHP4. This code includes a customization to take the viewer and set it to a % based size instead of using the .ini value. It only works if the .ini size is set to 700. This sets the width to 100% and height to 95% which works well in IE7 as tested. Comment or remove the 2 replacements referring to width and height if this is not disirable, but leave the code block within the if statement because you do not want the script to replace the dgate.exe references within the viewer page.


    Create the file and name it index.php and put it in the same directory as dgate.exe then set your $app_base variable, or create a resource file to include that has the $app_base variable set (see comments in the code):


    See below for updated version


    P.S. One thing I can't figure out: what is that little square at the top right that turns red when you click it for?

  • NOTE: Since I got my integrated auth working with dgate.exe above: If you use IIS with integrated authentication you will need to impliment something like the NTLM proxy described in user contributions on file_get_contents() of the php.net documentation to get access to dgate.exe through file_get_contents(). Alternatively you can just set the file security as anonymous access, but if you are looking for a smooth security setup with no extra logins then you can get it working like this. The latest version only allows connections from the local host by default so it's pretty secure.


    EDIT: Here is an updated version that works with the NTLM proxy for IIS6 integrated auth on dgate.exe. Make this into index.php in your dgate.exe directory and go in and set the $app_base variable either in this file or in a separate file to use in the require() line. This also gets more specific on the dgate.exe replacements to fix a problem viewing images outside of the viewer and creates a link on the viewer page to see a Low Res series view (max dsize=320) for faster image loading. See file comments for more info:


    See newest version below


    Lucas

  • Lucas this looks awesome, the only problem is I can't seem to get it working, (http://servername/cgi-bin/dgate.exe) works just fine, its just when I toss in your PHP file it doesnt work, I tried commenting out the auth portion (as I'm using APACHE, and it still blows up) can you point me in the right direction. (this looks very useful for setting the size of the viewer especially)


    Thanks!


    --Jason

  • Do you get any errors or warnings? The way I have it set up the index.php resides with the dgate.exe but make sure you can actually use php files in that directory on your webserver setup. The script will need some tweaking if you cannot view php files from within cgi-bin. I don't have any windows boxes running apache so I don't have a quick way to test it out. Try putting a file like test.php in the cgi-bin with nothing but: <? phpinfo(); ?> in the file and see if that returns the php config when you go to http://servername/cgi-bin/test.php


    Make sure when you comment out the NTLM part you *uncomment* the $rawstr portion below that for no auth required.

  • OK I tossed apache 2.2.9 and php5.2.6 on my workstation and it did NOT like to serve php from the cgi-bin. I have adjusted the file a bit to be more portable with some better coding standards and by default does not use the NTLM (must uncomment that and comment out the no auth to use it). Replace localhost with your webserver's proper domain name and the path after that to wherever you are running dgate.exe from. Put the php file created from the below code anywhere you like now and set the $php_wrapper value to point to that as a url relative to the root ("/path/filename.php") including the file name. The example below has it as index.php in the root directory with dgate.exe running from cgi-bin. I tested this on apache and on IIS with and without the NTLM and it worked for me in all cases. Also this might have some more of the features I've tweaked in like javascript resizing and the lowres option (not sure if I posted the last version before or after I added those).


  • Hi,


    Good to hear. Maybe you can still double check the abovelisted php wrapper, it still refers to 1.4.14beta, and I see 'Viwer size' instead of 'Viewer size'. I have not tried it though.


    Marcel

  • Thanks for the heads up.


    I edited the above code and updated it to strip the correct new header and body tags for replacemet later on and fixed the typo. It is designed for people who know some basics about html and php though so that they can customize their own look and feel. The only real features I add "out of the box" are the kpacs viewer sizing and lowres option.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!