Fix
This commit is contained in:
parent
3f7f9ce7e6
commit
73f3eb8178
4 changed files with 30 additions and 34 deletions
|
@ -1,27 +1,28 @@
|
|||
<?php
|
||||
namespace Includes;
|
||||
namespace includes;
|
||||
|
||||
use Classes\Xmpp;
|
||||
use Classes\Webhook;
|
||||
use Config\Config;
|
||||
use classes\xmpp;
|
||||
use classes\webhook;
|
||||
use config\config;
|
||||
|
||||
/**
|
||||
* Main Application Class
|
||||
* @package Includes
|
||||
*/
|
||||
class App
|
||||
class app
|
||||
{
|
||||
protected $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = new Config();
|
||||
$this->config = new config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Main application loop
|
||||
*/
|
||||
public function start(){
|
||||
public function start(): void
|
||||
{
|
||||
if($this->checkIfRequestMethodIsPost() && $this->checkAuthorization() && $this->checkIfIpOnWhitelistAndWhitelistEnabled()) {
|
||||
$this->handleIncomingData();
|
||||
}
|
||||
|
@ -31,43 +32,38 @@ class App
|
|||
* Check if client is authorized to post via this gate
|
||||
* @return bool
|
||||
*/
|
||||
private function checkAuthorization()
|
||||
private function checkAuthorization(): ?bool
|
||||
{
|
||||
if(isset($_GET['apikey']) && $_GET['apikey'] === $this->config->api_key)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
die("ERROR: Client not authenticated to use this application");
|
||||
}
|
||||
return false;
|
||||
|
||||
die("ERROR: Client not authenticated to use this application");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if whitelist and ip address is in whitelist
|
||||
*/
|
||||
private function checkIfIpOnWhitelistAndWhitelistEnabled(){
|
||||
private function checkIfIpOnWhitelistAndWhitelistEnabled(): bool
|
||||
{
|
||||
if($this->config->ip_whitelist)
|
||||
{
|
||||
if(in_array($this->getRealIPAddr(),$this->config->ips_whitelist_list))
|
||||
{
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Check if request method is post
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIfRequestMethodIsPost()
|
||||
private function checkIfRequestMethodIsPost(): bool
|
||||
{
|
||||
if($_SERVER["REQUEST_METHOD"])
|
||||
{
|
||||
|
@ -78,7 +74,7 @@ class App
|
|||
}
|
||||
|
||||
|
||||
private function handleIncomingData()
|
||||
private function handleIncomingData(): void
|
||||
{
|
||||
$post = file_get_contents("php://input");
|
||||
$wh = new Webhook($post);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue