Created
April 26, 2018 02:22
-
-
Save chrishieu/b0d021195757a6a45d56ca4f3a1b2566 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //writed by GoodCom | |
| //author:coolbi | |
| include_once("get_order.php"); | |
| $sRange = "0-1023"; | |
| $sUserAgent="Gc(2)/v0001"; | |
| $useraccount="testuser"; | |
| $userpwd="test"; | |
| $defaultcount="testuser"; | |
| $defaultpwd="test"; | |
| function SendOrderToPrinter($strOrder,$iStart,$iEnd) | |
| { | |
| $orderLength = strlen($strOrder); | |
| $sStr1 = ""; | |
| header("Content-type: "."application/octet-stream"); | |
| $toBytes=$iEnd; | |
| if ($toBytes>=$orderLength) { | |
| if($orderLength>1) { | |
| $toBytes=$orderLength-1; | |
| } else { | |
| $toBytes=1; | |
| } | |
| } | |
| $startBytes=$iStart; | |
| if (($startBytes>$orderLength)) { | |
| $startBytes=$toBytes; | |
| header("HTTP/1.1 416 Request Range Not Satisfialbe"); | |
| $sStr1=""; | |
| print substr($sStr1,$startBytes+1-1,$toBytes+1-$startBytes); | |
| } else { | |
| ob_end_clean(); //added to fix ZIP file corruption | |
| ob_start(); //added to fix ZIP file corruption | |
| $contentRange="bytes ".($startBytes)."-".($toBytes)."/".($orderLength); | |
| header("Content-Range".": ".$contentRange); | |
| $rangesize = ($toBytes+1 - $startBytes) > 0 ? ($toBytes+1 - $startBytes) : 0; | |
| $sStr1 = substr($strOrder,$startBytes,$rangesize); | |
| header("Content-Length:" .$rangesize); | |
| echo $sStr1; | |
| ob_flush(); | |
| flush(); | |
| } | |
| return 1; | |
| } | |
| if(isset($_SERVER["HTTP_RANGE"])) { | |
| $sRange=$_SERVER["HTTP_RANGE"]; | |
| } | |
| if(isset($_SERVER["HTTP_USER-AGENT"])) { | |
| $sUserAgent=$_SERVER["HTTP_USER-AGENT"]; | |
| } | |
| if(isset($_GET['u'])) { | |
| $useraccount=strtolower($_GET['u']); | |
| } | |
| if(isset($_GET['p'])) { | |
| $userpwd=strtolower($_GET['p']); | |
| } | |
| if(($useraccount==$defaultcount)&&($userpwd==$defaultpwd)) { | |
| if (($sRange!="")) { | |
| $strOrder=""; | |
| header("HTTP/1.1 206 Partial Content"); | |
| // $bytes=explode("=",$sRange); | |
| //var_dump($bytes); | |
| $range=explode("-",$sRange); | |
| $strOrder=GetOrderFromServer(); | |
| $startBytes=intval($range[0]); | |
| $toBytes=intval($range[1]); | |
| SendOrderToPrinter($strOrder,$startBytes,$toBytes); | |
| } else { | |
| print substr("",0,1); | |
| } | |
| } else { | |
| print substr("",0,1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment