Skip to content

Commit

Permalink
Extract URL base from hard-coded links, added changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
lubosdz committed May 14, 2019
1 parent 894dfe8 commit f689993
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
16 changes: 10 additions & 6 deletions ConnectorOrsr.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
/**
* Parser pre vypis z obchodneho registra SR
* (c) 2015 - 2017 lubosdz
* Version 1.0.2 (released 14.05.2019)
* (c) 2015 - 2019 lubosdz@gmail.com
* ------------------------------------------------------------------
* Disclaimer / Prehlásenie:
* Kód poskytnutý je bez záruky a môže kedykoľvek prestať fungovať.
Expand Down Expand Up @@ -49,7 +50,7 @@
namespace lubosdz\parserOrsr;

/**
* Slovak Business register DOM XML parser
* Slovak Business Register DOM XML parser
*/
class ConnectorOrsr
{
Expand All @@ -59,6 +60,9 @@ class ConnectorOrsr
const TYP_OSOBY_PRAVNICKA = 'pravnicka';
const TYP_OSOBY_FYZICKA = 'fyzicka';

// by extracting target URL it's easier to update if they switch to secure URL or remove www prefix etc.
const URL_BASE = 'http://www.orsr.sk';

// stores some data into local files to avoid multiple requests during development
public $debug = false;

Expand Down Expand Up @@ -254,7 +258,7 @@ public function getDetailById($id, $sid, $p=0){
// ID + SID = jedinecny identifikator subjektu
// SID (ID sudu dla kraja) = 1 .. 8 different companies :-(
// P = 1 - uplny, otherwise 0 = aktualny
$url = "http://www.orsr.sk/vypis.asp?ID={$id}&SID={$sid}&P={$p}";
$url = self::URL_BASE."/vypis.asp?ID={$id}&SID={$sid}&P={$p}";
$html = file_get_contents($url);
if($html && $this->debug){
file_put_contents($path, $html);
Expand Down Expand Up @@ -328,7 +332,7 @@ public function findByObchodneMeno($meno){
// http://www.orsr.sk/hladaj_subjekt.asp?OBMENO=sumia&PF=0&R=on
// R=on ... only aktualne zaznamy, otherwise hladaj aj v historickych zaznamoch
// PF=0 .. pravna forma (0 = any)
$url = "http://www.orsr.sk/hladaj_subjekt.asp?OBMENO={$meno}&PF=0&R=on";
$url = self::URL_BASE."/hladaj_subjekt.asp?OBMENO={$meno}&PF=0&R=on";
$html = file_get_contents($url);
if($html && $this->debug){
file_put_contents($path, $html);
Expand Down Expand Up @@ -358,7 +362,7 @@ public function getDetailByICO($ico){
// http://www.orsr.sk/hladaj_ico.asp?ICO=123&SID=0
// SID=0 .. sud ID (0 = any)
if(empty($html)){
$url = "http://www.orsr.sk/hladaj_ico.asp?ICO={$ico}&SID=0";
$url = self::URL_BASE."/hladaj_ico.asp?ICO={$ico}&SID=0";
$html = file_get_contents($url);
if($html && $this->debug){
file_put_contents($path, $html);
Expand Down Expand Up @@ -394,7 +398,7 @@ public function findByPriezviskoMeno($priezvisko, $meno = ''){
// R=on ... only aktualne zaznamy, otherwise hladaj aj v historickych zaznamoch
// PF=0 .. pravna forma (0 = any)
// SID=0 .. sud ID (0 = any)
$url = "http://www.orsr.sk/hladaj_osoba.asp?PR={$priezvisko}&MENO={$meno}&SID=0&T=f0&R=on";
$url = self::URL_BASE."/hladaj_osoba.asp?PR={$priezvisko}&MENO={$meno}&SID=0&T=f0&R=on";
$html = file_get_contents($url);
if($html && $this->debug){
file_put_contents($path, $html);
Expand Down
7 changes: 6 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,9 @@ $detail : Array
)
```

--------------------------------------------------
Changelog
---------

* 1.0.2 - [14.05.2019] fixed PCRE unicode handling in different environments
* 1.0.1 - [11.03.2019] fixed bug PHP7+ compatability
* 1.0.0 - [12.09.2018] initial release

0 comments on commit f689993

Please sign in to comment.