File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed
Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 2626 if ($ test ['code ' ] != 200 ) {
2727 $ error = 'Failed to connect with code: ' . $ test ['code ' ];
2828 } else {
29- $ result = 'Connection successful to ' . $ app . ': Instance ' . $ test ['response ' ]['instanceName ' ];
29+ if (str_contains ($ test ['response ' ], 'doctype ' )) {
30+ $ error = 'The starr app returned HTML, this typically happens with a bad base URL. ' ;
31+ } else {
32+ $ result = 'Connection successful to ' . $ app . ': Instance ' . $ test ['response ' ]['instanceName ' ];
33+ }
3034 }
3135
3236 echo json_encode (['error ' => $ error , 'result ' => $ result ]);
5761 $ name = 'ERROR ' ;
5862
5963 if ($ test ['code ' ] == 200 ) {
60- $ name = $ test ['response ' ]['instanceName ' ];
64+ if (str_contains ($ test ['response ' ], 'doctype ' )) {
65+ $ error = 'The starr app returned HTML, this typically happens with a bad base URL. ' ;
66+ } else {
67+ $ name = $ test ['response ' ]['instanceName ' ];
68+ }
6169 }
6270
6371 $ fields = [
6876 'password ' => rawurldecode ($ _POST ['password ' ])
6977 ];
7078
71- if ($ _POST ['starrId ' ] == '99 ' ) {
72- $ error = $ proxyDb ->addStarrApp ($ app , $ fields );
73- } else {
74- $ error = $ proxyDb ->updateStarrApp ($ _POST ['starrId ' ], $ fields );
79+ if (!$ error ) {
80+ if ($ _POST ['starrId ' ] == '99 ' ) {
81+ $ error = $ proxyDb ->addStarrApp ($ app , $ fields );
82+ } else {
83+ $ error = $ proxyDb ->updateStarrApp ($ _POST ['starrId ' ], $ fields );
84+ }
7585 }
7686
7787 echo $ error ;
Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ function testStarr(starrId, app)
2121 data : '&m=testStarr&starrId=' + starrId + '&url=' + $ ( '#instance-url-' + starrId ) . val ( ) + '&apikey=' + apikey + '&app=' + app ,
2222 dataType : 'json' ,
2323 success : function ( resultData ) {
24- let type = 'success' ;
2524 if ( resultData . error ) {
26- type = 'error' ;
25+ toast ( 'Starr test' , resultData . error , 'error' ) ;
26+ return ;
2727 }
2828
29- toast ( 'Starr test' , resultData . result , type ) ;
29+ toast ( 'Starr test' , resultData . result , 'success' ) ;
3030 }
3131 } ) ;
3232}
You can’t perform that action at this time.
0 commit comments