@@ -56,6 +56,20 @@ public function debug($which)
5656 $ this ->debug = $ which ;
5757 }
5858
59+ // Get Ahsay OBS License informations
60+ public function getLicense ()
61+ {
62+ $ this ->debugLog ("Get Ahsay OBS license informations " );
63+
64+ $ url = "/GetLicense.do " ;
65+ $ result = $ this ->runQuery ($ url );
66+
67+ // If that didn't happen
68+ $ this ->errorHandler ($ result , "Failed to get Ahsay OBS License informations. " );
69+
70+ return $ this ->decodeResult ($ result );
71+ }
72+
5973 // Authenticate a user against OBS
6074 public function authenticateUser ($ username , $ password )
6175 {
@@ -314,7 +328,7 @@ public function getDestinationID($username, $backupset, $backupjob)
314328 public function runQuery ($ url )
315329 {
316330 try {
317- if ($ this ->serverVersion == '6 ' ) {
331+ if ($ this ->serverVersion === '6 ' ) {
318332 $ url = $ this ->serverAddress .'/obs/api ' .$ url ;
319333
320334 // If this URL already has a query string
@@ -327,7 +341,7 @@ public function runQuery($url)
327341 $ this ->debuglog ("Trying $ url " );
328342 $ result = file_get_contents ($ url );
329343
330- } elseif ($ this ->serverVersion == '7 ' ) {
344+ } elseif ($ this ->serverVersion === '7 ' ) {
331345 if (strstr ($ url , '? ' )) {
332346 $ args =explode ('& ' , substr ($ url , strpos ($ url , '? ' ) +1 ));
333347 $ url = $ this ->serverAddress .'/obs/api/json ' .strstr ($ url , '? ' , TRUE );
@@ -375,9 +389,9 @@ public function runQuery($url)
375389 public function decodeResult ($ result )
376390 {
377391 try {
378- if ($ this ->serverVersion == '6 ' ) {
392+ if ($ this ->serverVersion === '6 ' ) {
379393 return simplexml_load_string ($ result );
380- } elseif ($ this ->serverVersion == '7 ' ) {
394+ } elseif ($ this ->serverVersion === '7 ' ) {
381395 return json_decode ($ result );
382396 } else {
383397 throw new Exception ("Please specify server version between 6 or 7 ! \e\n" );
@@ -392,13 +406,13 @@ public function decodeResult($result)
392406 public function errorHandler ($ result , $ message )
393407 {
394408 try {
395- if ($ this ->serverVersion == '6 ' ) {
396- if (substr ($ result , 1 , 3 ) == 'err ' ) {
409+ if ($ this ->serverVersion === '6 ' ) {
410+ if (substr ($ result , 1 , 3 ) === 'err ' ) {
397411 throw new Exception ($ message . "\r\n" . $ result . "\r\n" );
398412 }
399- } elseif ($ this ->serverVersion == '7 ' ) {
413+ } elseif ($ this ->serverVersion === '7 ' ) {
400414 $ status =json_decode ($ result , TRUE );
401- if ($ status ['Status ' ] == 'Error ' ) {
415+ if ($ status ['Status ' ] === 'Error ' ) {
402416 throw new Exception ($ message . "\r\n" . $ result . "\r\n" );
403417 }
404418 } else {
0 commit comments