Changeset 738 for trunk/Modules/FinanceBankAPI/Fio.php
- Timestamp:
- Apr 14, 2015, 10:20:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/FinanceBankAPI/Fio.php
r550 r738 1 1 <?php 2 2 3 3 include('GPC.php'); 4 5 class Fio 4 5 class Fio 6 6 { 7 7 var $UserName; 8 8 var $Password; 9 var $Account; 10 9 var $Account; 10 11 11 function Import($TimeFrom, $TimeTo) 12 12 { … … 14 14 if($this->Password == '') throw new Exception('Missing value for Password property.'); 15 15 if(!is_numeric($this->Account)) throw new Exception('Missing or not numeric value for Account property.'); 16 16 17 17 $fp = fsockopen('ssl://www.fio.cz', 443, $errno, $errstr, 30); 18 if(!$fp) 18 if(!$fp) 19 19 { 20 20 throw new Exception('Connection error: '.$errstr); 21 } else 21 } else 22 22 { 23 23 // Send request … … 32 32 $Request .= "Connection: Close\r\n\r\n"; 33 33 fwrite($fp, $Request); 34 34 35 35 // Read response 36 36 $Response = array(); 37 while(!feof($fp)) 37 while(!feof($fp)) 38 38 { 39 39 $Response[] = trim(fgets($fp, 1024)); 40 40 } 41 41 fclose($fp); 42 42 43 43 // Strip HTTP header 44 44 while($Response[0] != '') array_shift($Response); 45 45 array_shift($Response); // Remove empty line 46 46 //echo(implode("\n", $Response)); 47 47 48 48 // Parse all GPC lines 49 49 $GPC = new GPC(); … … 58 58 } 59 59 } 60 60 61 61 function NoValidDataError($Response) 62 62 { 63 63 // Try to get error message 64 64 // If something go wrong fio show HTML login page and display error message 65 65 $Response = implode('', $Response); 66 66 $ErrorMessageStart = '<div id="oldform_warning">'; 67 if(strpos($Response, $ErrorMessageStart) !== false) 68 69 70 71 72 67 if(strpos($Response, $ErrorMessageStart) !== false) 68 { 69 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart)); 70 $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>'))); 71 } else $ErrorMessage = ''; 72 throw new Exception('No valid GPC data: '.$ErrorMessage); 73 73 } 74 74 }
Note:
See TracChangeset
for help on using the changeset viewer.