Initial Upload

This commit is contained in:
Matt Batchelder
2025-12-02 10:32:59 -05:00
commit 05ce0da296
2240 changed files with 467811 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
class ChangeLayoutAction extends PlayerAction
{
public $layoutId;
public $duration;
public $downloadRequired;
public $changeMode;
public function __construct()
{
$this->setQos(10);
}
/**
* Set details for this layout
* @param int $layoutId the layoutId to change to
* @param int $duration the duration this layout should be shown
* @param bool|false $downloadRequired flag indicating whether a download is required before changing to the layout
* @param string $changeMode whether to queue or replace
* @return $this
*/
public function setLayoutDetails($layoutId, $duration = 0, $downloadRequired = false, $changeMode = 'queue')
{
if ($duration === null) {
$duration = 0;
}
$this->layoutId = $layoutId;
$this->duration = $duration;
$this->downloadRequired = $downloadRequired;
$this->changeMode = $changeMode;
return $this;
}
/**
* @inheritDoc
*/
public function getMessage(): string
{
$this->action = 'changeLayout';
if ($this->layoutId == 0) {
throw new PlayerActionException('Layout Details not provided');
}
return $this->serializeToJson(['layoutId', 'duration', 'downloadRequired', 'changeMode']);
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Class ClearStatsAndLogsAction
* @package Xibo\XMR
*/
class ClearStatsAndLogsAction extends PlayerAction
{
public function __construct()
{
$this->setQos(2);
}
public function getMessage(): string
{
$this->action = 'clearStatsAndLogs';
return $this->serializeToJson();
}
}

View File

@@ -0,0 +1,46 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Class CollectNowAction
* @package Xibo\XMR
*/
class CollectNowAction extends PlayerAction
{
public function __construct()
{
$this->setQos(5);
}
/**
* @inheritdoc
*/
public function getMessage()
{
$this->action = 'collectNow';
return $this->serializeToJson();
}
}

55
lib/XMR/CommandAction.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
class CommandAction extends PlayerAction
{
protected $commandCode;
public function __construct()
{
$this->setQos(8);
}
/**
* Set the command code
* @param string $code
* @return $this
*/
public function setCommandCode($code)
{
$this->commandCode = $code;
return $this;
}
public function getMessage(): string
{
$this->action = 'commandAction';
if ($this->commandCode == '') {
throw new PlayerActionException('Missing Command Code');
}
return $this->serializeToJson(['commandCode']);
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Class DataUpdateAction
* Used to indicate that a widget has been recently updated and should be downloaded again
* @package Xibo\XMR
*/
class DataUpdateAction extends PlayerAction
{
/**
* @param int $widgetId The widgetId which has been updated
*/
public function __construct(protected int $widgetId)
{
$this->setQos(5);
}
/** @inheritdoc */
public function getMessage(): string
{
$this->setQos(1);
$this->action = 'dataUpdate';
return $this->serializeToJson(['widgetId']);
}
}

View File

@@ -0,0 +1,45 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Class LicenceCheckAction
* @package Xibo\XMR
*/
class LicenceCheckAction extends PlayerAction
{
public function __construct()
{
$this->setQos(4);
}
/**
* @return string
*/
public function getMessage(): string
{
$this->action = 'licenceCheck';
return $this->serializeToJson();
}
}

View File

@@ -0,0 +1,74 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Class OverlayLayoutAction
* @package Xibo\XMR
*/
class OverlayLayoutAction extends PlayerAction
{
public $layoutId;
public $duration;
public $downloadRequired;
public $changeMode;
public function __construct()
{
$this->setQos(10);
}
/**
* Set details for this layout
* @param int $layoutId the layoutId to change to
* @param int $duration the duration this layout should be overlaid
* @param bool|false $downloadRequired flag indicating whether a download is required before changing to the layout
* @return $this
*/
public function setLayoutDetails($layoutId, $duration, $downloadRequired = false)
{
$this->layoutId = $layoutId;
$this->duration = $duration;
$this->downloadRequired = $downloadRequired;
return $this;
}
/**
* @inheritdoc
*/
public function getMessage(): string
{
$this->action = 'overlayLayout';
if ($this->layoutId == 0) {
throw new PlayerActionException(__('Layout Details not provided'));
}
if ($this->duration == 0) {
throw new PlayerActionException(__('Duration not provided'));
}
return $this->serializeToJson(['layoutId', 'duration', 'downloadRequired']);
}
}

178
lib/XMR/PlayerAction.php Normal file
View File

@@ -0,0 +1,178 @@
<?php
/*
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* An adstract class which implements a Player Action Interface
* This class should be extended for each different action type
*
* When sending it will check that a default QOS/TTL has been configured. It is the responsibility
* of the extending class to set this on initialisation.
*/
abstract class PlayerAction implements PlayerActionInterface
{
/** @var string The Action */
public $action;
/** @var string Created Date */
public $createdDt;
/** @var int TTL */
public $ttl;
/** @var int QOS */
private $qos;
/** @var string Channel */
private $channel;
/** @var string Public Key */
private $publicKey;
/** @var bool Should the message be encrypted? */
private bool $isEncrypted;
/**
* Set the identity of this Player Action
* @param string $channel
* @param bool $isEncrypted
* @param string|null $key
* @return $this
* @throws \Xibo\XMR\PlayerActionException if the key is invalid
*/
final public function setIdentity(string $channel, bool $isEncrypted, ?string $key): PlayerActionInterface
{
$this->channel = $channel;
$this->isEncrypted = $isEncrypted;
if ($isEncrypted) {
$this->publicKey = openssl_get_publickey($key);
if (!$this->publicKey) {
throw new PlayerActionException('Invalid Public Key');
}
}
return $this;
}
/**
* Set the message TTL
* @param int $ttl
* @return $this
*/
final public function setTtl(int $ttl = 120): PlayerAction
{
$this->ttl = $ttl;
return $this;
}
/**
* Set the message QOS
* @param int $qos
* @return $this
*/
final public function setQos(int $qos = 1): PlayerAction
{
$this->qos = $qos;
return $this;
}
/**
* Serialize this object to its JSON representation
* @param array $include
* @return string
*/
final public function serializeToJson(array $include = []): string
{
$include = array_merge(['action', 'createdDt', 'ttl'], $include);
$json = [];
foreach (get_object_vars($this) as $key => $value) {
if (in_array($key, $include)) {
$json[$key] = $value;
}
}
return json_encode($json);
}
/**
* Return the encrypted message and keys
* @return array
* @throws PlayerActionException
*/
private function getEncryptedMessage(): array
{
$message = null;
$seal = openssl_seal($this->getMessage(), $message, $eKeys, [$this->publicKey], 'RC4');
if (!$seal) {
throw new PlayerActionException('Cannot seal message');
}
return [
'key' => base64_encode($eKeys[0]),
'message' => base64_encode($message)
];
}
/**
* Finalise the message to be sent
* @throws \Xibo\XMR\PlayerActionException
*/
final public function finaliseMessage(): array
{
// Set the message create date
$this->createdDt = date('c');
// Set the TTL if not already set
if (empty($this->ttl)) {
$this->setTtl();
}
// Set the QOS if not already set
if (empty($this->qos)) {
$this->setQos();
}
// Envelope our message
$message = [
'channel' => $this->channel,
'qos' => $this->qos,
];
// Encrypt the message if needed.
if ($this->isEncrypted) {
$encrypted = $this->getEncryptedMessage();
$message['message'] = $encrypted['message'];
$message['key'] = $encrypted['key'];
$message['isWebSocket'] = false;
} else {
$message['message'] = $this->getMessage();
$message['key'] = 'none';
$message['isWebSocket'] = true;
}
return $message;
}
}

View File

@@ -0,0 +1,15 @@
<?php
/*
* Spring Signage Ltd - http://www.springsignage.com
* Copyright (C) 2015 Spring Signage Ltd
* (PlayerActionException.php)
*/
namespace Xibo\XMR;
class PlayerActionException extends \Exception
{
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Interface PlayerActionInterface
* @package Xibo\XMR
*/
interface PlayerActionInterface
{
/**
* Get the Message
* @return string
*/
public function getMessage();
}

View File

@@ -0,0 +1,45 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Class PurgeAllAction
* @package Xibo\XMR
*/
class PurgeAllAction extends PlayerAction
{
public function __construct()
{
$this->setQos(2);
}
/**
* @return string
*/
public function getMessage(): string
{
$this->action = 'purgeAll';
return $this->serializeToJson();
}
}

40
lib/XMR/RekeyAction.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
class RekeyAction extends PlayerAction
{
public function __construct()
{
$this->setQos(1);
}
public function getMessage(): string
{
$this->action = 'rekeyAction';
return $this->serializeToJson();
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
class RevertToSchedule extends PlayerAction
{
public function __construct()
{
$this->setQos(10);
}
public function getMessage(): string
{
$this->action = 'revertToSchedule';
return $this->serializeToJson();
}
}

View File

@@ -0,0 +1,67 @@
<?php
/*
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Class ScheduleCriteriaUpdateAction
* @package Xibo\XMR
*/
class ScheduleCriteriaUpdateAction extends PlayerAction
{
/**
* @var array
*/
public $criteriaUpdates = [];
public function __construct()
{
$this->setQos(10);
}
/**
* Set criteria updates
* @param array $criteriaUpdates an array of criteria updates
* @return $this
*/
public function setCriteriaUpdates(array $criteriaUpdates)
{
$this->criteriaUpdates = $criteriaUpdates;
return $this;
}
/**
* @inheritdoc
*/
public function getMessage(): string
{
$this->action = 'criteriaUpdate';
// Ensure criteriaUpdates array is not empty
if (empty($this->criteriaUpdates)) {
// Throw an exception if criteriaUpdates is not provided
throw new PlayerActionException(__('Criteria updates not provided.'));
}
return $this->serializeToJson(['criteriaUpdates']);
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
class ScreenShotAction extends PlayerAction
{
public function __construct()
{
$this->setQos(5);
}
public function getMessage(): string
{
$this->action = 'screenShot';
return $this->serializeToJson();
}
}

View File

@@ -0,0 +1,53 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Xibo\XMR;
/**
* Trigger a web hook on the player. This is intended mainly for testing purposes as you'd
* expect the trigger to be sent locally on the player
*/
class TriggerWebhookAction extends PlayerAction
{
public $triggerCode;
public function __construct($triggerCode)
{
$this->triggerCode = $triggerCode;
$this->setQos(3);
}
/**
* @return string
* @throws PlayerActionException
*/
public function getMessage(): string
{
$this->action = 'triggerWebhook';
if ($this->triggerCode == '') {
throw new PlayerActionException('Layout Details not provided');
}
return $this->serializeToJson(['triggerCode']);
}
}