From d2255e78fd51c12a3604316a53864692217c492f Mon Sep 17 00:00:00 2001 From: Brian Gregg Date: Fri, 11 Sep 2015 14:42:41 -0400 Subject: [PATCH 1/2] Added Print Queue option and enabled default hostname for missing default client address (useful when running from command line). --- PhpNetworkLprPrinter.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/PhpNetworkLprPrinter.php b/PhpNetworkLprPrinter.php index 766bb5b..2510c95 100644 --- a/PhpNetworkLprPrinter.php +++ b/PhpNetworkLprPrinter.php @@ -45,6 +45,15 @@ class PhpNetworkLprPrinter{ * @since 1.0 */ var $_username = "PhpNetworkLprPrinter"; + + /** + * Queue for printer + * + * @var string + * @access protected + * @since 1.0 + */ + var $_queue; /** * Error number if connection fails @@ -78,11 +87,13 @@ class PhpNetworkLprPrinter{ * * @param string The printer's host * @param integer The printer's port + * @param string The printer's queue * @since 1.0 */ - public function __construct($host, $port=515) { + public function __construct($host, $port=515, $queue="defaultQueue") { $this->_host = $host; $this->_port = $port; + $this->_queue = $queue; } /** @@ -188,11 +199,11 @@ private function connect(){ private function makecfA($jobid){ $this->setMessage("Setting cfA control String"); - $hostname = $_SERVER['REMOTE_ADDR']; + $hostname = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR']:getHostByName(getHostName()); $cfa = ""; $cfa .= "H" . $hostname . "\n"; //hostname $cfa .= "P" . $this->_username . "\n"; //user - $cfA .= "fdfA" + $jobid + $hostname + "\n"; + $cfa .= "fdfA" + $jobid + $hostname + "\n"; //TODO: Add more parameters. See http://www.faqs.org/rfcs/rfc1179.html return $cfa; @@ -246,7 +257,7 @@ public function printWaitingJobs($queue) { public function printText($text=""){ //Initial data - $queue="defaultQueue"; //TODO: Change default queue + $queue=$this->_queue; $jobid=001; //TODO: Autoincrement $jobid //Print any waiting job From bc60cbdd0c8e7178e0fb43a35016e57513cc114e Mon Sep 17 00:00:00 2001 From: Brian Gregg Date: Fri, 9 Nov 2018 11:15:23 -0500 Subject: [PATCH 2/2] Fixed reference to errStr and errNo with error_msg and error_number respectively. --- PhpNetworkLprPrinter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PhpNetworkLprPrinter.php b/PhpNetworkLprPrinter.php index 2510c95..ad8aa4a 100644 --- a/PhpNetworkLprPrinter.php +++ b/PhpNetworkLprPrinter.php @@ -152,7 +152,7 @@ public function setTimeOut($timeout){ * @since 1.0 */ public function getErrNo(){ - return $this->_errNo; + return $this->_error_number; } /** @@ -163,7 +163,7 @@ public function getErrNo(){ * @since 1.0 */ public function getErrStr(){ - return $this->_errStr; + return $this->_error_msg; } /**