Skip to content

Commit 039cf66

Browse files
committed
- updated to work properly with subdomains and ssl
1 parent c2b5b79 commit 039cf66

36 files changed

+289
-240
lines changed

Diff for: angular/src/app/auth/auth-interceptor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable, Injector } from '@angular/core';
22
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
3-
import { Observable } from 'rxjs/Observable';
3+
import { Observable } from 'rxjs';
44

55
@Injectable()
66
export class AuthInterceptor implements HttpInterceptor {

Diff for: angular/src/app/callout-details/callout-details.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { Location } from '@angular/common';
4-
import { Observable } from 'rxjs/Observable';
4+
import { Observable } from 'rxjs';
55

66
import { AuthService } from '@app/auth';
77

Diff for: angular/src/app/common/send-message.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { Location } from '@angular/common';
4-
import { Observable } from 'rxjs/Observable';
4+
import { Observable } from 'rxjs';
55

66
import { AuthService } from '@app/auth';
77

Diff for: angular/src/app/common/system-config.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { Location } from '@angular/common';
4-
import { Observable } from 'rxjs/Observable';
4+
import { Observable } from 'rxjs';
55

66
@Injectable()
77
export class SystemConfigService {
88

9-
url_action = '/../angular-services/system-config-service.php/config';
9+
url_action = '/../angular-services/system-config-service.php?/config';
1010
url = '';
1111

1212
constructor(private http: HttpClient, private location: Location) {

Diff for: angular/src/app/menu-callout-history/menu-callout-history.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { Location } from '@angular/common';
4-
import { Observable } from 'rxjs/Observable';
4+
import { Observable } from 'rxjs';
55

66
import { AuthService } from '@app/auth';
77

Diff for: angular/src/app/menu-user-accounts/user-accounts.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { Location } from '@angular/common';
4-
import { Observable } from 'rxjs/Observable';
4+
import { Observable } from 'rxjs';
55

66
import { AuthService } from '@app/auth';
77
import { DeleteDataService } from '@app/common';

Diff for: php/angular-services/system-config-service.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,32 @@
1414

1515
require_once __RIPRUNNER_ROOT__ . '/logging.php';
1616
require_once __RIPRUNNER_ROOT__ . '/rest/WebApi.php';
17+
require_once __RIPRUNNER_ROOT__ . '/config.php';
18+
require_once __RIPRUNNER_ROOT__ . '/models/global-model.php';
1719
require_once __RIPRUNNER_ROOT__ . '/models/main-menu-model.php';
1820

1921
use Vanen\Mvc\Api;
2022
use Vanen\Mvc\ApiController;
23+
use Vanen\Net\HttpResponse;
2124

2225
class SystemConfigController extends ApiController {
2326

2427
private $isXml = false;
25-
28+
2629
public function __controller() {
30+
global $log;
31+
if ($log !== null) $log->trace("System Config controller startup.");
32+
2733
$this->JSON_OPTIONS = JSON_PRETTY_PRINT;
2834
$this->RESPONSE_TYPE = 'JSON';
2935
$this->isXml = strcasecmp($this->RESPONSE_TYPE, 'xml') === 0;
3036
}
3137

3238
/** :GET :{method} */
3339
public function config($fhid=null) {
40+
global $log;
41+
if ($log !== null) $log->trace("System Config controller config method.");
42+
3443
$systemConfigModel = new \riprunner\MainMenuViewModel();
3544
$systemConfig = array();
3645
//$systemConfig['hasUpdate'] = true;
@@ -69,4 +78,4 @@ private function getFirehall($fhid) {
6978
}
7079

7180
$api = new Api();
72-
$api->handle();
81+
$api->handle();

Diff for: php/config_constants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// ==============================================================
1919

2020
define( 'PRODUCT_NAME', 'RipRunner' );
21-
define( 'PRODUCT_URL', 'http://soft-haus.com' );
21+
define( 'PRODUCT_URL', 'https://soft-haus.com' );
2222
define( 'DEBUG_MODE', false);
2323
define( 'ENABLE_AUDITING', true);
2424
define( 'SECURE', false); // FOR DEVELOPMENT ONLY!!!!

Diff for: php/googleae/email-poller/riprunner-trigger.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

33
// Point to the Main Email trigger URL which will poll for all Firehalls
4-
// Example replace: http://soft-haus.com/svvfd/riprunner/ with the root of you installation
5-
$result = file_get_contents('http://soft-haus.com/svvfd/riprunner/email_trigger_check.php?'.mt_rand());
4+
// Example replace: https://svvfd.soft-haus.com/ with the root of you installation
5+
$result = file_get_contents('https://svvfd.soft-haus.com/email_trigger_check.php?'.mt_rand());
66

77
echo 'Got Results:' . PHP_EOL;
88
echo $result;

Diff for: php/googleae/email-webhook/incoming-email-webhook.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
);
4545
$context = stream_context_create($context);
4646

47-
$url = "http://soft-haus.com/svvfd/riprunner/webhooks/email_trigger_webhook.php";
47+
$url = "https://svvfd.soft-haus.com/webhooks/email_trigger_webhook.php";
4848
$result = file_get_contents($url, false, $context);
4949

5050
syslog(LOG_INFO,"PHP Result of calling webhook url: ". $result);

Diff for: php/googleae/email-webhook/incoming-email-webhook.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def receive(self, mail_message):
1717
logging.info("Body of message: " + body[1].decode())
1818

1919
# Point to the Main Email trigger URL which will poll for all Firehalls
20-
# Example replace: http://soft-haus.com/svvfd/riprunner/ with the root of you installation
21-
url = "http://soft-haus.com/svvfd/riprunner/webhooks/email_trigger_webhook.php"
20+
# Example replace: https://svvfd.soft-haus.com/ with the root of you installation
21+
url = "https://svvfd.soft-haus.com/webhooks/email_trigger_webhook.php"
2222
form_fields = {
2323
"sender": mail_message.sender,
2424
"subject": mail_message.subject,

Diff for: php/rest/WebApi.php

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?php
22
namespace Vanen\Net;
3+
if(defined('__RIPRUNNER_ROOT__') === false) {
4+
define('__RIPRUNNER_ROOT__', dirname(dirname(__FILE__)));
5+
}
6+
7+
require_once __RIPRUNNER_ROOT__ . '/logging.php';
38

49
function getRequestSetting($type, $variable_name) {
510
$result = filter_input($type, $variable_name);
@@ -18,6 +23,9 @@ class HttpResponse
1823
public function __construct($statusCode = 200, $message = 'Ok', $object = null)
1924
{
2025
$serverProtocol = getRequestSetting(INPUT_SERVER, 'SERVER_PROTOCOL');
26+
//if(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == on) {
27+
// $serverProtocol = 'HTTPS';
28+
//}
2129

2230
$this->statusCode = $statusCode;
2331
$this->message = "$serverProtocol $statusCode $message";
@@ -82,10 +90,14 @@ final class Api
8290

8391
public function __construct($version = null)
8492
{
93+
global $log;
94+
8595
if ($version) {
8696
$this->version = trim($version, '/\\');
8797
}
8898
$this->mHttpMethod = \Vanen\Net\getRequestSetting(INPUT_SERVER, 'REQUEST_METHOD');
99+
100+
if ($log !== null) $log->trace('Web API Controller constructor using method: '.$this->mHttpMethod);
89101
}
90102

91103
/**
@@ -94,6 +106,9 @@ public function __construct($version = null)
94106
*/
95107
public function handle()
96108
{
109+
global $log;
110+
if ($log !== null) $log->trace('Web API Controller handle method start.');
111+
97112
$parsedInfo = $this->parseRequest();
98113

99114
$_httpResponse = "Vanen\\Net\\HttpResponse";
@@ -196,37 +211,51 @@ private function respond($response)
196211
//
197212
private function parseRequest()
198213
{
214+
global $log;
199215
$methodNotAllowed = false;
200216

217+
$failReason = 0;
201218
// Get information about all controllers.
202219
foreach ($this->getControllerInfo() ?: [] as $controller => $methods) {
203220
foreach ($methods as $method) {
204221
// Skip this method if it doesn't accept this request method.
205222
if (!in_array($this->mHttpMethod, $method->http_verbs)) {
206223
$methodNotAllowed = true;
224+
225+
$failReason = 1;
226+
if ($log !== null) $log->trace('Web API Controller lookup fail reason: '.$failReason. ' for: '.$this->mHttpMethod);
227+
207228
continue;
208229
}
209230

210231
// Filter all information from the URI using the pattern of this method.
211232
$uriInfo = $this->filterUri($method->uri_pattern);
212233
if (!$uriInfo) {
234+
$failReason = 2;
213235
continue;
214236
}
215237

216238
// Skip this controller if it was not requested.
217239
if (property_exists($uriInfo, 'controller') && $uriInfo->controller !== null &&
218240
strcasecmp(substr($controller, 0, -10), $uriInfo->controller) !== 0) {
241+
242+
$failReason = 3;
243+
if ($log !== null) $log->trace('Web API Controller lookup fail reason: '.$failReason. ' for: '.$controller);
219244
break;
220245
}
221246

222247
// Skip this method if it was not requested.
223248
if (property_exists($uriInfo, 'method') && $uriInfo->method !== null &&
224249
strcasecmp($method->name, $uriInfo->method) !== 0) {
250+
$failReason = 4;
251+
if ($log !== null) $log->trace('Web API Controller lookup fail reason: '.$failReason. ' for: '.$method->name.' URI Info: '.$uriInfo->method);
225252
continue;
226253
}
227254

228255
// Skip this method if more parameters were passed than it takes.
229256
if (count($uriInfo->parameters) > count($method->parameters)) {
257+
$failReason = 5;
258+
if ($log !== null) $log->trace('Web API Controller lookup fail reason: '.$failReason. ' for: '.$method->parameters);
230259
continue;
231260
}
232261

@@ -244,6 +273,8 @@ private function parseRequest()
244273
$parameters[$param->name] = $param->default;
245274
} else {
246275
$parameters = false;
276+
$failReason = 6;
277+
if ($log !== null) $log->trace('Web API Controller lookup fail reason: '.$failReason. ' for: '.$param->name);
247278
break;
248279
}
249280
}
@@ -267,8 +298,10 @@ private function parseRequest()
267298
// Resource was found but the method is not allowed.
268299
return new \Vanen\Net\HttpResponse(405, 'Method Not Allowed');
269300
}
270-
return new \Vanen\Net\HttpResponse(404, 'Not Found');
301+
302+
if ($log !== null) $log->trace('Web API Controller lookup returning 404 reason: '.$failReason);
271303

304+
return new \Vanen\Net\HttpResponse(404, 'Not Found reason:');
272305
}
273306

274307
//
@@ -481,4 +514,4 @@ private function xml_encode($mixed, $domElement = null, $DOMDocument = null)
481514
}
482515
}
483516
}
484-
}
517+
}

Diff for: php/routes.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
global $FIREHALLS;
3838

3939
$root_url = getFirehallRootURLFromRequest(\Flight::request()->url, $FIREHALLS);
40-
\Flight::redirect($root_url .'ngui/index.html');
40+
\Flight::redirect($root_url .'/ngui/index.html');
4141
});
4242

4343
\Flight::route('GET|POST /', function () {
@@ -46,8 +46,8 @@
4646
//parse_str($params, $query);
4747

4848
$root_url = getFirehallRootURLFromRequest(\Flight::request()->url, $FIREHALLS);
49-
//\Flight::redirect($root_url .'controllers/login-controller.php?' . $params);
50-
\Flight::redirect($root_url .'controllers/login-controller.php');
49+
//\Flight::redirect($root_url .'/controllers/login-controller.php?' . $params);
50+
\Flight::redirect($root_url .'/controllers/login-controller.php');
5151
});
5252

5353
\Flight::route('GET|POST /login|/logon(/@params)', function ($params) {
@@ -56,15 +56,15 @@
5656
parse_str($params, $query);
5757

5858
$root_url = getFirehallRootURLFromRequest(\Flight::request()->url, $FIREHALLS);
59-
\Flight::redirect($root_url .'controllers/login-controller.php?' . $params);
59+
\Flight::redirect($root_url .'/controllers/login-controller.php?' . $params);
6060
});
6161

6262
\Flight::route('GET|POST /mobile-login/(@params)', function ($params) {
6363
global $FIREHALLS;
6464
$query = array();
6565
parse_str($params, $query);
6666
$root_url = getFirehallRootURLFromRequest(\Flight::request()->url, $FIREHALLS);
67-
\Flight::redirect($root_url .'controllers/login-device-controller.php?' . $params);
67+
\Flight::redirect($root_url .'/controllers/login-device-controller.php?' . $params);
6868
});
6969

7070
\Flight::route('GET|POST /test/(@params)', function ($params) {
@@ -78,7 +78,7 @@
7878
parse_str($params, $query);
7979
$root_url = getFirehallRootURLFromRequest(\Flight::request()->url, $FIREHALLS);
8080

81-
\Flight::redirect($root_url .'controllers/callout-details-controller.php?' . $params);
81+
\Flight::redirect($root_url .'/controllers/callout-details-controller.php?' . $params);
8282
});
8383

8484
\Flight::route('GET|POST /cr/(@params)', function ($params) {
@@ -90,8 +90,8 @@
9090
parse_str($params, $query);
9191
$root_url = getFirehallRootURLFromRequest(\Flight::request()->url, $FIREHALLS);
9292

93-
$log->warn("Route got CR about to redirect to: ".$root_url .'controllers/callout-response-controller.php?' . $params);
94-
\Flight::redirect($root_url .'controllers/callout-response-controller.php?' . $params);
93+
$log->warn("Route got CR about to redirect to: ".$root_url .'/controllers/callout-response-controller.php?' . $params);
94+
\Flight::redirect($root_url .'/controllers/callout-response-controller.php?' . $params);
9595
});
9696

9797
\Flight::route('GET|POST /ct/(@params)', function ($params) {
@@ -100,7 +100,7 @@
100100
parse_str($params, $query);
101101
$root_url = getFirehallRootURLFromRequest(\Flight::request()->url, $FIREHALLS);
102102

103-
\Flight::redirect($root_url .'controllers/callout-tracking-controller.php?' . $params);
103+
\Flight::redirect($root_url .'/controllers/callout-tracking-controller.php?' . $params);
104104
});
105105

106106
\Flight::route('GET|POST /android-error/(@params)', function ($params) {

Diff for: php/views/access-denied.twig.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<p>
22
<span class="error">You are not authorized to access this page.</span>
3-
Please <a href="{{ gvm.RR_DOC_ROOT }}login">login</a>.
3+
Please <a href="{{ gvm.RR_DOC_ROOT }}/login">login</a>.
44
</p>

0 commit comments

Comments
 (0)