<?php
header('Cache-Control: no-cache, no-store, must-revalidate');   
header('Expires: 0');

//  error_reporting(E_ALL);
//  ini_set('display_errors', 1);  

// Print Server

$mConnect   		= $_GET['connection'];
$mUser				= $_GET['user'];
$mPwd				= $_GET['pword'];
$mHost              = $_GET['host'];
$mDbName			= $_GET['dbase'];

$mOutput			= $_GET['output'];
$mPrinter			= $_GET['printer'];

if (($mPrinter == null) || ($mPrinter == "") || (!$mPrinter))
	$mPrinter = "172.16.1.42";

$mPath = "../../../vimsreports";

$mFiles = array_diff(scandir($mPath), array('.', '..'));
foreach ($mFiles as $mFile)
{
	$fp = fsockopen($mPrinter, 9100, $errno, $errstr, 30);
//	$mFile = $mPath."/".$mFile;
	$mLines = file_get_contents($mPath."/".$mFile);
	print_r("File:".$mPath."/".$mFile."-".filesize($mPath."/".$mFile));
	print_r('"C:/Program Files (x86)/Adobe/Acrobat Reader DC/Reader/AcroRd32.exe" /t C:/web/veldb/vimsreports/'.$mFile);
	shell_exec('"C:/Program Files (x86)/Adobe/Acrobat Reader DC/Reader/AcroRd32.exe" /t C:/web/veldb/vimsreports/'.$mFile);
//	fprintf($fp,$mLines);
/*
	$mFh = fopen($mFile, 'r');
	print_r("File:".$mFile."-".filesize($mFile));
	$i = 0;
	while (!feof($mFile))
	{
		$mLine = fgets($mFile, 1024);
		$i++;
		print_r("Line:".$i);
//		fprintf($fp,$mLine);
		fputs($fp, $mLine);
	}
*/
	fclose($fp);
}
// fclose($mFile);
?>