From 7b1ba42e66ca7ea8f9052cd96c206c2691edeefe Mon Sep 17 00:00:00 2001 From: D3strukt0r Date: Mon, 29 Jun 2026 22:00:00 +0200 Subject: [PATCH 01/13] style: reformat the source to the new coding standard Apply the PHP-CS-Fixer ruleset across src/ (Yoda conditions removed, fully-qualified built-in functions and classes, import cleanups, PHPDoc ordering, concatenation spacing). No behaviour changes; the actual bug fixes follow in their own commits so they aren't buried in reformatting. --- src/Exception/NotVotifierException.php | 6 +- .../NuVotifierChallengeInvalidException.php | 4 +- src/Exception/NuVotifierException.php | 6 +- .../NuVotifierSignatureInvalidException.php | 4 +- .../NuVotifierUnknownServiceException.php | 4 +- .../NuVotifierUsernameTooLongException.php | 4 +- .../Socket/NoConnectionException.php | 6 +- .../Socket/PackageNotReceivedException.php | 6 +- .../Socket/PackageNotSentException.php | 6 +- src/Server/GenericServer.php | 2 +- src/Server/NuVotifier.php | 58 +++++++++---------- src/Server/ServerInterface.php | 9 ++- src/Server/Votifier.php | 48 ++++++++------- src/Socket.php | 14 ++--- src/Vote/ClassicVote.php | 8 +-- src/Vote/VoteInterface.php | 14 ++--- 16 files changed, 82 insertions(+), 117 deletions(-) diff --git a/src/Exception/NotVotifierException.php b/src/Exception/NotVotifierException.php index 19dcc63..fe62c89 100644 --- a/src/Exception/NotVotifierException.php +++ b/src/Exception/NotVotifierException.php @@ -12,12 +12,8 @@ namespace D3strukt0r\Votifier\Client\Exception; -use Exception; - /** * Class NotVotifierException * The connection does not belong to Votifier. */ -class NotVotifierException extends Exception -{ -} +class NotVotifierException extends \Exception {} diff --git a/src/Exception/NuVotifierChallengeInvalidException.php b/src/Exception/NuVotifierChallengeInvalidException.php index 41c0d55..07fc749 100644 --- a/src/Exception/NuVotifierChallengeInvalidException.php +++ b/src/Exception/NuVotifierChallengeInvalidException.php @@ -16,6 +16,4 @@ * Class NuVotifierChallengeInvalidException * Challenge is not valid. */ -class NuVotifierChallengeInvalidException extends NuVotifierException -{ -} +class NuVotifierChallengeInvalidException extends NuVotifierException {} diff --git a/src/Exception/NuVotifierException.php b/src/Exception/NuVotifierException.php index 1a6ba17..a7dc598 100644 --- a/src/Exception/NuVotifierException.php +++ b/src/Exception/NuVotifierException.php @@ -12,8 +12,4 @@ namespace D3strukt0r\Votifier\Client\Exception; -use Exception; - -class NuVotifierException extends Exception -{ -} +class NuVotifierException extends \Exception {} diff --git a/src/Exception/NuVotifierSignatureInvalidException.php b/src/Exception/NuVotifierSignatureInvalidException.php index 2afcf78..9748a88 100644 --- a/src/Exception/NuVotifierSignatureInvalidException.php +++ b/src/Exception/NuVotifierSignatureInvalidException.php @@ -16,6 +16,4 @@ * Class NuVotifierSignatureInvalidException * Signature is not valid (invalid token?). */ -class NuVotifierSignatureInvalidException extends NuVotifierException -{ -} +class NuVotifierSignatureInvalidException extends NuVotifierException {} diff --git a/src/Exception/NuVotifierUnknownServiceException.php b/src/Exception/NuVotifierUnknownServiceException.php index 12eaa1d..df9ee9b 100644 --- a/src/Exception/NuVotifierUnknownServiceException.php +++ b/src/Exception/NuVotifierUnknownServiceException.php @@ -16,6 +16,4 @@ * Class NuVotifierUnknownServiceException * Unknown service 'xxx'. */ -class NuVotifierUnknownServiceException extends NuVotifierException -{ -} +class NuVotifierUnknownServiceException extends NuVotifierException {} diff --git a/src/Exception/NuVotifierUsernameTooLongException.php b/src/Exception/NuVotifierUsernameTooLongException.php index 3baec55..71272f1 100644 --- a/src/Exception/NuVotifierUsernameTooLongException.php +++ b/src/Exception/NuVotifierUsernameTooLongException.php @@ -16,6 +16,4 @@ * Class NuVotifierUsernameTooLongException * Username too long. */ -class NuVotifierUsernameTooLongException extends NuVotifierException -{ -} +class NuVotifierUsernameTooLongException extends NuVotifierException {} diff --git a/src/Exception/Socket/NoConnectionException.php b/src/Exception/Socket/NoConnectionException.php index 1b540a1..bcdabec 100644 --- a/src/Exception/Socket/NoConnectionException.php +++ b/src/Exception/Socket/NoConnectionException.php @@ -12,8 +12,4 @@ namespace D3strukt0r\Votifier\Client\Exception\Socket; -use Exception; - -class NoConnectionException extends Exception -{ -} +class NoConnectionException extends \Exception {} diff --git a/src/Exception/Socket/PackageNotReceivedException.php b/src/Exception/Socket/PackageNotReceivedException.php index 095dfae..4495a0f 100644 --- a/src/Exception/Socket/PackageNotReceivedException.php +++ b/src/Exception/Socket/PackageNotReceivedException.php @@ -12,12 +12,8 @@ namespace D3strukt0r\Votifier\Client\Exception\Socket; -use Exception; - /** * Class PackageNotReceivedException * Unable to read server response. */ -class PackageNotReceivedException extends Exception -{ -} +class PackageNotReceivedException extends \Exception {} diff --git a/src/Exception/Socket/PackageNotSentException.php b/src/Exception/Socket/PackageNotSentException.php index dddb11a..9ca3879 100644 --- a/src/Exception/Socket/PackageNotSentException.php +++ b/src/Exception/Socket/PackageNotSentException.php @@ -12,12 +12,8 @@ namespace D3strukt0r\Votifier\Client\Exception\Socket; -use Exception; - /** * Class PackageNotSentException * Couldn't write to remote host. */ -class PackageNotSentException extends Exception -{ -} +class PackageNotSentException extends \Exception {} diff --git a/src/Server/GenericServer.php b/src/Server/GenericServer.php index d06f352..7e66e54 100644 --- a/src/Server/GenericServer.php +++ b/src/Server/GenericServer.php @@ -46,7 +46,7 @@ abstract class GenericServer implements ServerInterface */ public function getSocket(): Socket { - return null === $this->socket ? $this->socket = new Socket() : $this->socket; + return $this->socket === null ? $this->socket = new Socket() : $this->socket; } /** diff --git a/src/Server/NuVotifier.php b/src/Server/NuVotifier.php index d9201bd..0ec30cc 100644 --- a/src/Server/NuVotifier.php +++ b/src/Server/NuVotifier.php @@ -19,10 +19,6 @@ use D3strukt0r\Votifier\Client\Exception\NuVotifierUnknownServiceException; use D3strukt0r\Votifier\Client\Exception\NuVotifierUsernameTooLongException; use D3strukt0r\Votifier\Client\Vote\VoteInterface; -use DateTime; -use InvalidArgumentException; - -use function count; /** * The Class to access a server which uses the plugin "NuVotifier". @@ -35,7 +31,7 @@ class NuVotifier extends Votifier protected $protocolV2 = false; /** - * @var string|null The token from the config.yml + * @var null|string The token from the config.yml */ protected $token; @@ -66,7 +62,7 @@ public function setProtocolV2(bool $isProtocolV2): self /** * Gets the token from the config.yml. * - * @return string|null returns The token from the config.yml + * @return null|string returns The token from the config.yml */ public function getToken(): ?string { @@ -76,7 +72,7 @@ public function getToken(): ?string /** * Sets the token from the config.yml. * - * @param string|null $token The token from the config.yml + * @param null|string $token The token from the config.yml * * @return $this returns the class itself, for doing multiple things at once */ @@ -141,7 +137,7 @@ public function sendVote(VoteInterface ...$votes): void $challenge = mb_substr($headerParts[2], 0, -1); // Update the timestamp of the vote being sent - $vote->setTimestamp(new DateTime()); + $vote->setTimestamp(new \DateTime()); // Check if all variables have been set, to create a package $this->checkVariablesForPackage($vote); @@ -160,16 +156,20 @@ public function sendVote(VoteInterface ...$votes): void * {"status":"error","cause":"CorruptedFrameException","error":"Username too long"} (over 16 characters) */ $result = json_decode($socket->read(256)); - if ('ok' !== $result->status) { - if ('Challenge is not valid' === $result->error) { + if ($result->status !== 'ok') { + if ($result->error === 'Challenge is not valid') { throw new NuVotifierChallengeInvalidException(); - } elseif (preg_match('/Unknown service \'(.*)\'/', $result->error)) { + } + if (preg_match('/Unknown service \'(.*)\'/', $result->error)) { throw new NuVotifierUnknownServiceException(); - } elseif ('Signature is not valid (invalid token?)' === $result->error) { + } + if ($result->error === 'Signature is not valid (invalid token?)') { throw new NuVotifierSignatureInvalidException(); - } elseif ('Username too long' === $result->error) { + } + if ($result->error === 'Username too long') { throw new NuVotifierUsernameTooLongException(); } + throw new NuVotifierException('Unknown NuVotifier Exception'); } @@ -183,9 +183,9 @@ public function sendVote(VoteInterface ...$votes): void * * @param VoteInterface $vote The vote to check * - * @throws InvalidArgumentException If one required parameter wasn't set + * @throws \InvalidArgumentException If one required parameter wasn't set */ - protected function checkVariablesForPackage(VoteInterface $vote) + protected function checkVariablesForPackage(VoteInterface $vote): void { if (!$this->isProtocolV2()) { parent::checkVariablesForSocket(); @@ -194,30 +194,30 @@ protected function checkVariablesForPackage(VoteInterface $vote) } if ( - null === $vote->getServiceName() - || null === $vote->getUsername() - || null === $vote->getAddress() - || null === $vote->getTimestamp() + $vote->getServiceName() === null + || $vote->getUsername() === null + || $vote->getAddress() === null + || $vote->getTimestamp() === null || !isset($this->token) ) { $countError = 0; $errorMessage = ''; - if (null === $vote->getServiceName()) { + if ($vote->getServiceName() === null) { $errorMessage .= 'The host variable wasn\'t set with "->setServiceName(...)".'; ++$countError; } - if (null === $vote->getUsername()) { + if ($vote->getUsername() === null) { $errorMessage .= $countError > 0 ? ' ' : ''; $errorMessage .= 'The host variable wasn\'t set with "->setUsername(...)".'; ++$countError; } - if (null === $vote->getAddress()) { + if ($vote->getAddress() === null) { $errorMessage .= $countError > 0 ? ' ' : ''; $errorMessage .= 'The host variable wasn\'t set with "->setAddress(...)".'; ++$countError; } - if (null === $vote->getTimestamp()) { + if ($vote->getTimestamp() === null) { $errorMessage .= $countError > 0 ? ' ' : ''; $errorMessage .= 'The host variable wasn\'t set with "->setTimestamp(...)".'; } @@ -226,14 +226,14 @@ protected function checkVariablesForPackage(VoteInterface $vote) $errorMessage .= 'The token variable wasn\'t set with "->setToken(...)".'; } - throw new InvalidArgumentException($errorMessage); + throw new \InvalidArgumentException($errorMessage); } } /** * Verifies that the connection is correct. * - * @param string|null $header The header that the plugin usually sends + * @param null|string $header The header that the plugin usually sends * * @return bool returns true if connections is available, otherwise false */ @@ -241,9 +241,9 @@ protected function verifyConnectionHeader(?string $header): bool { $header_parts = explode(' ', $header); if ( - null === $header - || false === mb_strpos($header, 'VOTIFIER') - || 3 !== count($header_parts) + $header === null + || mb_strpos($header, 'VOTIFIER') === false + || \count($header_parts) !== 3 ) { return false; } @@ -274,6 +274,6 @@ protected function preparePackageV2(VoteInterface $vote, string $challenge): str $messageJson = json_encode(['signature' => $signature, 'payload' => $payloadJson]); // 0x733a = s: - return pack('nn', 0x733a, mb_strlen($messageJson)) . $messageJson; + return pack('nn', 0x733A, mb_strlen($messageJson)).$messageJson; } } diff --git a/src/Server/ServerInterface.php b/src/Server/ServerInterface.php index 0c38161..81d8f9e 100644 --- a/src/Server/ServerInterface.php +++ b/src/Server/ServerInterface.php @@ -17,7 +17,6 @@ use D3strukt0r\Votifier\Client\Exception\Socket\PackageNotReceivedException; use D3strukt0r\Votifier\Client\Exception\Socket\PackageNotSentException; use D3strukt0r\Votifier\Client\Vote\VoteInterface; -use InvalidArgumentException; /** * The interface ServerInterface is used to define a PluginType on the server. @@ -27,7 +26,7 @@ interface ServerInterface /** * Gets the host. * - * @return string|null returns the host + * @return null|string returns the host */ public function getHost(): ?string; @@ -59,7 +58,7 @@ public function setPort(int $port); /** * Gets the public key. * - * @return string|null returns the public key + * @return null|string returns the public key */ public function getPublicKey(): ?string; @@ -75,7 +74,7 @@ public function setPublicKey(string $publicKey); /** * Checks if the server actually belongs to Votifier. * - * @throws InvalidArgumentException If one required parameter wasn't set + * @throws \InvalidArgumentException If one required parameter wasn't set * @throws NoConnectionException If connection couldn't be established * @throws PackageNotReceivedException If there was an error receiving the package * @throws NotVotifierException If the server we are connected to is not a valid Votifier server @@ -87,7 +86,7 @@ public function verifyConnection(): void; * * @param VoteInterface ...$votes The vote packages * - * @throws InvalidArgumentException If one required parameter wasn't set + * @throws \InvalidArgumentException If one required parameter wasn't set * @throws NoConnectionException If connection couldn't be established * @throws PackageNotReceivedException If there was an error receiving the package * @throws PackageNotSentException If there was an error sending the package diff --git a/src/Server/Votifier.php b/src/Server/Votifier.php index da1f566..d98d955 100644 --- a/src/Server/Votifier.php +++ b/src/Server/Votifier.php @@ -14,8 +14,6 @@ use D3strukt0r\Votifier\Client\Exception\NotVotifierException; use D3strukt0r\Votifier\Client\Vote\VoteInterface; -use DateTime; -use InvalidArgumentException; /** * The Class to access a server which uses the classic "Votifier" plugin. @@ -59,7 +57,7 @@ public function sendVote(VoteInterface ...$votes): void } // Update the timestamp of the vote being sent - $vote->setTimestamp(new DateTime()); + $vote->setTimestamp(new \DateTime()); // Check if all variables have been set, to create a package $this->checkVariablesForPackage($vote); @@ -75,7 +73,7 @@ public function sendVote(VoteInterface ...$votes): void /** * Check that both host and port have been set. * - * @throws InvalidArgumentException If one required parameter wasn't set + * @throws \InvalidArgumentException If one required parameter wasn't set */ protected function checkVariablesForSocket(): void { @@ -83,7 +81,7 @@ protected function checkVariablesForSocket(): void // $countError = 0; $errorMessage = ''; - if (null === $this->host) { + if ($this->host === null) { $errorMessage .= 'The host variable wasn\'t set with "->setHost(...)".'; // ++$countError; } @@ -93,7 +91,7 @@ protected function checkVariablesForSocket(): void // $errorMessage .= 'The port variable wasn\'t set with "->setPort(...)".'; // } - throw new InvalidArgumentException($errorMessage); + throw new \InvalidArgumentException($errorMessage); } } @@ -102,35 +100,35 @@ protected function checkVariablesForSocket(): void * * @param VoteInterface $vote The vote to check * - * @throws InvalidArgumentException If one required parameter wasn't set + * @throws \InvalidArgumentException If one required parameter wasn't set */ - protected function checkVariablesForPackage(VoteInterface $vote) + protected function checkVariablesForPackage(VoteInterface $vote): void { if ( - null === $vote->getServiceName() - || null === $vote->getUsername() - || null === $vote->getAddress() - || null === $vote->getTimestamp() + $vote->getServiceName() === null + || $vote->getUsername() === null + || $vote->getAddress() === null + || $vote->getTimestamp() === null || !isset($this->publicKey) ) { $countError = 0; $errorMessage = ''; - if (null === $vote->getServiceName()) { + if ($vote->getServiceName() === null) { $errorMessage .= 'The host variable wasn\'t set with "->setServiceName(...)".'; ++$countError; } - if (null === $vote->getUsername()) { + if ($vote->getUsername() === null) { $errorMessage .= $countError > 0 ? ' ' : ''; $errorMessage .= 'The host variable wasn\'t set with "->setUsername(...)".'; ++$countError; } - if (null === $vote->getAddress()) { + if ($vote->getAddress() === null) { $errorMessage .= $countError > 0 ? ' ' : ''; $errorMessage .= 'The host variable wasn\'t set with "->setAddress(...)".'; ++$countError; } - if (null === $vote->getTimestamp()) { + if ($vote->getTimestamp() === null) { $errorMessage .= $countError > 0 ? ' ' : ''; $errorMessage .= 'The host variable wasn\'t set with "->setTimestamp(...)".'; } @@ -139,7 +137,7 @@ protected function checkVariablesForPackage(VoteInterface $vote) $errorMessage .= 'The public key variable wasn\'t set with "->setPublicKey(...)".'; } - throw new InvalidArgumentException($errorMessage); + throw new \InvalidArgumentException($errorMessage); } } @@ -147,15 +145,15 @@ protected function checkVariablesForPackage(VoteInterface $vote) * Verifies that the connection is correct. Read more: * https://github.com/vexsoftware/votifier/wiki/Protocol-Documentation. * - * @param string|null $header The header that the plugin usually sends + * @param null|string $header The header that the plugin usually sends * * @return bool returns true if connections is available, otherwise false */ protected function verifyConnectionHeader(?string $header): bool { if ( - null === $header - || false === mb_strpos($header, 'VOTIFIER') + $header === null + || mb_strpos($header, 'VOTIFIER') === false ) { return false; } @@ -174,11 +172,11 @@ protected function verifyConnectionHeader(?string $header): bool protected function preparePackage(VoteInterface $vote): string { // Details of the vote - $votePackage = 'VOTE' . "\n" . - $vote->getServiceName() . "\n" . - $vote->getUsername() . "\n" . - $vote->getAddress() . "\n" . - $vote->getTimestamp() . "\n"; + $votePackage = 'VOTE'."\n" + .$vote->getServiceName()."\n" + .$vote->getUsername()."\n" + .$vote->getAddress()."\n" + .$vote->getTimestamp()."\n"; // Encrypt the string openssl_public_encrypt($votePackage, $encryptedVotePackage, $this->getPublicKey(), OPENSSL_SSLV23_PADDING); diff --git a/src/Socket.php b/src/Socket.php index c63edfe..e0ee2fb 100644 --- a/src/Socket.php +++ b/src/Socket.php @@ -33,7 +33,7 @@ class Socket */ public function __destruct() { - if (is_resource($this->socket)) { + if (\is_resource($this->socket)) { fclose($this->socket); } } @@ -49,7 +49,7 @@ public function __destruct() public function open(string $host, int $port): void { $socket = @fsockopen($host, $port, $errorNumber, $errorString, 3); - if (false === $socket) { + if ($socket === false) { throw new NoConnectionException($errorString, $errorNumber); } $this->socket = $socket; @@ -65,11 +65,11 @@ public function open(string $host, int $port): void */ public function write(string $string): void { - if (!is_resource($this->socket)) { + if (!\is_resource($this->socket)) { throw new NoConnectionException(); } - if (false === fwrite($this->socket, $string)) { + if (fwrite($this->socket, $string) === false) { throw new PackageNotSentException(); } } @@ -79,14 +79,14 @@ public function write(string $string): void * * @param int $length [optional] The length of the requested string * + * @return string returns the string received from the server + * * @throws NoConnectionException If connection has not been set up * @throws PackageNotReceivedException If there was an error receiving the package - * - * @return string returns the string received from the server */ public function read(int $length = 64): string { - if (!is_resource($this->socket)) { + if (!\is_resource($this->socket)) { throw new NoConnectionException(); } diff --git a/src/Vote/ClassicVote.php b/src/Vote/ClassicVote.php index d9fa426..b5f6807 100644 --- a/src/Vote/ClassicVote.php +++ b/src/Vote/ClassicVote.php @@ -12,8 +12,6 @@ namespace D3strukt0r\Votifier\Client\Vote; -use DateTime; - /** * The classic vote package can be used by most plugins. */ @@ -35,7 +33,7 @@ class ClassicVote implements VoteInterface protected $address; /** - * @var DateTime the time when the vote will be sent + * @var \DateTime the time when the vote will be sent */ protected $timestamp; @@ -105,9 +103,9 @@ public function getTimestamp(): ?int /** * {@inheritdoc} */ - public function setTimestamp(DateTime $timestamp = null): self + public function setTimestamp(?\DateTime $timestamp = null): self { - $this->timestamp = $timestamp ?: new DateTime(); + $this->timestamp = $timestamp ?: new \DateTime(); return $this; } diff --git a/src/Vote/VoteInterface.php b/src/Vote/VoteInterface.php index d49be06..43c3183 100644 --- a/src/Vote/VoteInterface.php +++ b/src/Vote/VoteInterface.php @@ -12,8 +12,6 @@ namespace D3strukt0r\Votifier\Client\Vote; -use DateTime; - /** * The interface VoteInterface will be used for different kinds of vote packages. */ @@ -22,7 +20,7 @@ interface VoteInterface /** * Gets the name of the list/service. * - * @return string|null returns the name of the list/service + * @return null|string returns the name of the list/service */ public function getServiceName(): ?string; @@ -38,7 +36,7 @@ public function setServiceName(string $serviceName); /** * Gets the username of the user who wants to receive the rewards. * - * @return string|null returns the username who wants to receive the rewards + * @return null|string returns the username who wants to receive the rewards */ public function getUsername(): ?string; @@ -54,7 +52,7 @@ public function setUsername(string $username); /** * Gets the IP Address of the user. * - * @return string|null returns the IP Address of the user + * @return null|string returns the IP Address of the user */ public function getAddress(): ?string; @@ -70,16 +68,16 @@ public function setAddress(string $address); /** * Gets the time when the vote was sent. * - * @return int|null returns the time when the vote was sent, null otherwise + * @return null|int returns the time when the vote was sent, null otherwise */ public function getTimestamp(): ?int; /** * Sets the time when the vote will be sent. * - * @param DateTime|null $timestamp [optional] Either give a wanted timestamp or it will use the current time + * @param null|\DateTime $timestamp [optional] Either give a wanted timestamp or it will use the current time * * @return $this returns the class itself, for doing multiple things at once */ - public function setTimestamp(DateTime $timestamp = null); + public function setTimestamp(?\DateTime $timestamp = null); } From ef4600b3b84585c6ac5d3605e57122e1ca253ab6 Mon Sep 17 00:00:00 2001 From: D3strukt0r Date: Mon, 29 Jun 2026 22:05:00 +0200 Subject: [PATCH 02/13] fix: encrypt classic Votifier packets with PKCS#1 v1.5 padding Classic Votifier encryption used OPENSSL_SSLV23_PADDING, a constant OpenSSL 3.0 removed and that is undefined on PHP 8, so encryption failed on modern stacks. Encrypt with openssl_public_encrypt's default PKCS#1 v1.5 padding instead, which is exactly what Votifier decrypts with (Cipher.getInstance("RSA") resolves to PKCS#1 v1.5 via the JDK's SunJCE provider). The public key is now parsed with openssl_pkey_get_public up front, so an invalid key throws an InvalidArgumentException instead of silently producing an empty packet, and the PEM body is wrapped at 64 characters. --- src/Server/GenericServer.php | 2 +- src/Server/Votifier.php | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Server/GenericServer.php b/src/Server/GenericServer.php index 7e66e54..c3a722e 100644 --- a/src/Server/GenericServer.php +++ b/src/Server/GenericServer.php @@ -112,7 +112,7 @@ public function getPublicKey(): ?string */ public function setPublicKey(string $publicKey): self { - $publicKey = wordwrap($publicKey, 65, "\n", true); + $publicKey = wordwrap($publicKey, 64, "\n", true); $publicKey = <<getAddress()."\n" .$vote->getTimestamp()."\n"; - // Encrypt the string - openssl_public_encrypt($votePackage, $encryptedVotePackage, $this->getPublicKey(), OPENSSL_SSLV23_PADDING); + // Parse the PEM public key up front so an invalid key fails loudly here + // instead of openssl_public_encrypt() silently producing an empty packet. + $publicKey = openssl_pkey_get_public($this->getPublicKey()); + if ($publicKey === false) { + throw new \InvalidArgumentException('The public key set with "->setPublicKey(...)" is not a valid RSA public key.'); + } + + // Encrypt with openssl_public_encrypt's default PKCS#1 v1.5 padding, which is + // what Votifier decrypts with (Cipher.getInstance("RSA") resolves to PKCS#1 + // v1.5 via the JDK's default SunJCE provider). The old explicit + // OPENSSL_SSLV23_PADDING was removed in OpenSSL 3.0 and is undefined on PHP 8.x. + openssl_public_encrypt($votePackage, $encryptedVotePackage, $publicKey); return $encryptedVotePackage; } From 95bd6ddc8179cca1c21d2ebd8b3d13cf2011d744 Mon Sep 17 00:00:00 2001 From: D3strukt0r Date: Mon, 29 Jun 2026 22:10:00 +0200 Subject: [PATCH 03/13] fix: support PHP 7.1 through 8.5 Replace the deprecated call_user_func_array([$this, 'parent::sendVote'], ...) parent-call form, which no longer works as a callable on newer PHP, with parent::sendVote(...$votes). --- src/Server/NuVotifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server/NuVotifier.php b/src/Server/NuVotifier.php index 0ec30cc..4b975d6 100644 --- a/src/Server/NuVotifier.php +++ b/src/Server/NuVotifier.php @@ -114,7 +114,7 @@ public function verifyConnection(): void public function sendVote(VoteInterface ...$votes): void { if (!$this->isProtocolV2()) { - call_user_func_array([$this, 'parent::sendVote'], func_get_args()); + parent::sendVote(...$votes); return; } From 27bbfb88ec3a63459c6f1a73cdce74d690996f1b Mon Sep 17 00:00:00 2001 From: D3strukt0r Date: Mon, 29 Jun 2026 22:15:00 +0200 Subject: [PATCH 04/13] fix: time out and report when a server sends no response fsockopen only set a connect timeout, so the first read blocked for php.ini's default_socket_timeout (60s) before failing with the vague "package not received". Set an explicit read timeout via stream_set_timeout and, when a read times out, throw a PackageNotReceivedException explaining that the server accepted the connection but sent nothing and that the host and Votifier port (default 8192, not the Minecraft port 25565) should be checked. Closes #5 --- src/Socket.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Socket.php b/src/Socket.php index e0ee2fb..245db1f 100644 --- a/src/Socket.php +++ b/src/Socket.php @@ -23,6 +23,19 @@ */ class Socket { + /** + * @var int Seconds to wait for the TCP connection to be established + */ + private const CONNECT_TIMEOUT = 3; + + /** + * @var int Seconds to wait for a response (the greeting and the NuVotifier v2 + * reply). Generous enough that a slow or distant server doesn't trip a + * false timeout, but far below PHP's 60s default_socket_timeout, which + * previously made an unresponsive endpoint hang for a full minute. + */ + private const READ_TIMEOUT = 10; + /** * @var resource the connection to the server */ @@ -48,10 +61,13 @@ public function __destruct() */ public function open(string $host, int $port): void { - $socket = @fsockopen($host, $port, $errorNumber, $errorString, 3); + $socket = @fsockopen($host, $port, $errorNumber, $errorString, self::CONNECT_TIMEOUT); if ($socket === false) { throw new NoConnectionException($errorString, $errorNumber); } + // Cap the wait for a response; otherwise reads block for php.ini's + // default_socket_timeout (60s) before failing. + stream_set_timeout($socket, self::READ_TIMEOUT); $this->socket = $socket; } @@ -91,6 +107,10 @@ public function read(int $length = 64): string } if (!$string = fread($this->socket, $length)) { + if (stream_get_meta_data($this->socket)['timed_out']) { + throw new PackageNotReceivedException('The server accepted the connection but did not respond within '.self::READ_TIMEOUT.' seconds. Check that the host and the Votifier port (default 8192, not the Minecraft port 25565) are correct and reachable.'); + } + throw new PackageNotReceivedException(); } From 4aee88d73c6e95c7303edd9cffbbc8a13810249e Mon Sep 17 00:00:00 2001 From: D3strukt0r Date: Mon, 29 Jun 2026 22:20:00 +0200 Subject: [PATCH 05/13] fix: include the underlying reason and host when a connection can't be opened When fsockopen fails, the OS-level reason (connection refused, timed out, no route to host, DNS failure) was discarded and the caller only saw a generic "could not create a connection". Surface that reason, along with the host and port, in the NoConnectionException message so the cause is visible. Closes #4 --- src/Socket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Socket.php b/src/Socket.php index 245db1f..79bcbce 100644 --- a/src/Socket.php +++ b/src/Socket.php @@ -63,7 +63,7 @@ public function open(string $host, int $port): void { $socket = @fsockopen($host, $port, $errorNumber, $errorString, self::CONNECT_TIMEOUT); if ($socket === false) { - throw new NoConnectionException($errorString, $errorNumber); + throw new NoConnectionException(\sprintf('Could not connect to %s:%d (%s). Make sure the Votifier port (default 8192, not the Minecraft port 25565) is open and reachable from this host.', $host, $port, $errorString !== '' ? $errorString : 'unknown error'), $errorNumber); } // Cap the wait for a response; otherwise reads block for php.ini's // default_socket_timeout (60s) before failing. From 919905fc307289b0a20fdef1e39f84d62c90a019 Mon Sep 17 00:00:00 2001 From: D3strukt0r Date: Mon, 29 Jun 2026 22:25:00 +0200 Subject: [PATCH 06/13] docs: overhaul the Sphinx documentation Generate the CC BY-NC-SA license page from the official source, pull the community-health files from the Team-MaRo/.github submodule instead of duplicating them, and drop the committed phpDocumentor API dump. --- .gitmodules | 3 + .readthedocs.yml | 20 +- docs/LICENSE.txt | 437 ++++++++++++++++++ docs/requirements.txt | 2 + docs/source/_community | 1 + docs/source/_static/.gitignore | 0 docs/source/_static/css/custom.css | 7 +- docs/source/_templates/.gitignore | 0 .../api/Exception/NotVotifierException.rst | 8 - .../NuVotifierChallengeInvalidException.rst | 8 - .../api/Exception/NuVotifierException.rst | 8 - .../NuVotifierSignatureInvalidException.rst | 8 - .../NuVotifierUnknownServiceException.rst | 8 - .../NuVotifierUsernameTooLongException.rst | 8 - .../Socket/NoConnectionException.rst | 8 - .../Socket/PackageNotReceivedException.rst | 8 - .../Socket/PackageNotSentException.rst | 8 - docs/source/api/Exception/Socket/index.rst | 14 - docs/source/api/Exception/index.rst | 24 - docs/source/api/Server/GenericServer.rst | 82 ---- docs/source/api/Server/NuVotifier.rst | 219 --------- docs/source/api/Server/ServerInterface.rst | 98 ---- docs/source/api/Server/Votifier.rst | 158 ------- docs/source/api/Server/index.rst | 21 - docs/source/api/Socket.rst | 47 -- docs/source/api/Vote/ClassicVote.rst | 82 ---- docs/source/api/Vote/VoteInterface.rst | 66 --- docs/source/api/Vote/index.rst | 13 - docs/source/api/index.rst | 25 +- docs/source/appendix/changelog.rst | 62 +-- docs/source/appendix/code-of-conduct.rst | 54 +-- docs/source/appendix/contributing.rst | 33 +- .../contributing/code-style-guidelines.rst | 33 -- .../contributing/pull-request-workflow.rst | 8 - .../contributing/ways-to-contribute.rst | 7 - docs/source/appendix/copyright.rst | 160 +------ docs/source/appendix/faq.rst | 5 - docs/source/appendix/sponsors.rst | 5 - docs/source/conf.py | 35 +- docs/source/getting-started/prerequisites.rst | 16 +- docs/source/getting-started/votifier.rst | 10 + docs/source/index.rst | 4 +- docs/update-license.py | 276 +++++++++++ phpdoc.dist.xml | 6 +- 44 files changed, 851 insertions(+), 1254 deletions(-) create mode 100644 .gitmodules create mode 100644 docs/LICENSE.txt create mode 160000 docs/source/_community delete mode 100644 docs/source/_static/.gitignore delete mode 100644 docs/source/_templates/.gitignore delete mode 100644 docs/source/api/Exception/NotVotifierException.rst delete mode 100644 docs/source/api/Exception/NuVotifierChallengeInvalidException.rst delete mode 100644 docs/source/api/Exception/NuVotifierException.rst delete mode 100644 docs/source/api/Exception/NuVotifierSignatureInvalidException.rst delete mode 100644 docs/source/api/Exception/NuVotifierUnknownServiceException.rst delete mode 100644 docs/source/api/Exception/NuVotifierUsernameTooLongException.rst delete mode 100644 docs/source/api/Exception/Socket/NoConnectionException.rst delete mode 100644 docs/source/api/Exception/Socket/PackageNotReceivedException.rst delete mode 100644 docs/source/api/Exception/Socket/PackageNotSentException.rst delete mode 100644 docs/source/api/Exception/Socket/index.rst delete mode 100644 docs/source/api/Exception/index.rst delete mode 100644 docs/source/api/Server/GenericServer.rst delete mode 100644 docs/source/api/Server/NuVotifier.rst delete mode 100644 docs/source/api/Server/ServerInterface.rst delete mode 100644 docs/source/api/Server/Votifier.rst delete mode 100644 docs/source/api/Server/index.rst delete mode 100644 docs/source/api/Socket.rst delete mode 100644 docs/source/api/Vote/ClassicVote.rst delete mode 100644 docs/source/api/Vote/VoteInterface.rst delete mode 100644 docs/source/api/Vote/index.rst delete mode 100644 docs/source/appendix/contributing/code-style-guidelines.rst delete mode 100644 docs/source/appendix/contributing/pull-request-workflow.rst delete mode 100644 docs/source/appendix/contributing/ways-to-contribute.rst delete mode 100644 docs/source/appendix/faq.rst delete mode 100644 docs/source/appendix/sponsors.rst create mode 100755 docs/update-license.py diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d40c984 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "docs/source/_community"] + path = docs/source/_community + url = https://github.com/Team-MaRo/.github.git diff --git a/.readthedocs.yml b/.readthedocs.yml index 1ddcede..ceb7c45 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -4,6 +4,17 @@ # Required version: 2 +# Set the build environment (build.os and build.tools are now required) +build: + os: ubuntu-24.04 + tools: + python: "latest" + jobs: + pre_build: + # Generate the formatted Markdown license (docs/LICENSE.md) from the + # official legalcode; the plain-text original lives at docs/LICENSE.txt. + - python docs/update-license.py + # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/source/conf.py @@ -11,8 +22,13 @@ sphinx: # Optionally build your docs in additional formats such as PDF and ePub formats: all -# Optionally set the version of Python and requirements required to build your docs +# Install the Python requirements needed to build the docs python: - version: 3.7 install: - requirements: docs/requirements.txt + +# Pull in the shared community-health files (Code of Conduct, Contributing) +# from the central Team-MaRo/.github repo so they are not duplicated here. +submodules: + include: + - docs/source/_community diff --git a/docs/LICENSE.txt b/docs/LICENSE.txt new file mode 100644 index 0000000..cbe5ad1 --- /dev/null +++ b/docs/LICENSE.txt @@ -0,0 +1,437 @@ +Attribution-NonCommercial-ShareAlike 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International +Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-NonCommercial-ShareAlike 4.0 International Public License +("Public License"). To the extent this Public License may be +interpreted as a contract, You are granted the Licensed Rights in +consideration of Your acceptance of these terms and conditions, and the +Licensor grants You such rights in consideration of benefits the +Licensor receives from making the Licensed Material available under +these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-NC-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution, NonCommercial, and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. NonCommercial means not primarily intended for or directed towards + commercial advantage or monetary compensation. For purposes of + this Public License, the exchange of the Licensed Material for + other material subject to Copyright and Similar Rights by digital + file-sharing or similar means is NonCommercial provided there is + no payment of monetary compensation in connection with the + exchange. + + l. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + m. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + n. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part, for NonCommercial purposes only; and + + b. produce, reproduce, and Share Adapted Material for + NonCommercial purposes only. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties, including when + the Licensed Material is used other than for NonCommercial + purposes. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-NC-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database for NonCommercial purposes + only; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + including for purposes of Section 3(b); and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/docs/requirements.txt b/docs/requirements.txt index 4c35754..d8956d2 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,4 @@ sphinx_rtd_theme sphinxcontrib-phpdomain +myst-parser +beautifulsoup4 diff --git a/docs/source/_community b/docs/source/_community new file mode 160000 index 0000000..a00dd75 --- /dev/null +++ b/docs/source/_community @@ -0,0 +1 @@ +Subproject commit a00dd75bbac7e43135f598be9706dafaa54471d1 diff --git a/docs/source/_static/.gitignore b/docs/source/_static/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/docs/source/_static/css/custom.css b/docs/source/_static/css/custom.css index 7d393f5..e177ff0 100644 --- a/docs/source/_static/css/custom.css +++ b/docs/source/_static/css/custom.css @@ -1,8 +1,5 @@ -.bold-italic { - font-weight: bold; - font-style: italic; -} - +/* The generated license (docs/LICENSE.rst) marks defined terms with the + reStructuredText :underline: role, which docutils renders as this class. */ .underline { text-decoration: underline; } diff --git a/docs/source/_templates/.gitignore b/docs/source/_templates/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/docs/source/api/Exception/NotVotifierException.rst b/docs/source/api/Exception/NotVotifierException.rst deleted file mode 100644 index e7e145e..0000000 --- a/docs/source/api/Exception/NotVotifierException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception** - -==================== -NotVotifierException -==================== - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception -.. php:exception:: NotVotifierException diff --git a/docs/source/api/Exception/NuVotifierChallengeInvalidException.rst b/docs/source/api/Exception/NuVotifierChallengeInvalidException.rst deleted file mode 100644 index c6917c5..0000000 --- a/docs/source/api/Exception/NuVotifierChallengeInvalidException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception** - -=================================== -NuVotifierChallengeInvalidException -=================================== - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception -.. php:exception:: NuVotifierChallengeInvalidException diff --git a/docs/source/api/Exception/NuVotifierException.rst b/docs/source/api/Exception/NuVotifierException.rst deleted file mode 100644 index bc0b8ee..0000000 --- a/docs/source/api/Exception/NuVotifierException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception** - -=================== -NuVotifierException -=================== - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception -.. php:exception:: NuVotifierException diff --git a/docs/source/api/Exception/NuVotifierSignatureInvalidException.rst b/docs/source/api/Exception/NuVotifierSignatureInvalidException.rst deleted file mode 100644 index a1a89ff..0000000 --- a/docs/source/api/Exception/NuVotifierSignatureInvalidException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception** - -=================================== -NuVotifierSignatureInvalidException -=================================== - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception -.. php:exception:: NuVotifierSignatureInvalidException diff --git a/docs/source/api/Exception/NuVotifierUnknownServiceException.rst b/docs/source/api/Exception/NuVotifierUnknownServiceException.rst deleted file mode 100644 index 77bf83a..0000000 --- a/docs/source/api/Exception/NuVotifierUnknownServiceException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception** - -================================= -NuVotifierUnknownServiceException -================================= - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception -.. php:exception:: NuVotifierUnknownServiceException diff --git a/docs/source/api/Exception/NuVotifierUsernameTooLongException.rst b/docs/source/api/Exception/NuVotifierUsernameTooLongException.rst deleted file mode 100644 index 6b4bf91..0000000 --- a/docs/source/api/Exception/NuVotifierUsernameTooLongException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception** - -================================== -NuVotifierUsernameTooLongException -================================== - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception -.. php:exception:: NuVotifierUsernameTooLongException diff --git a/docs/source/api/Exception/Socket/NoConnectionException.rst b/docs/source/api/Exception/Socket/NoConnectionException.rst deleted file mode 100644 index da322ab..0000000 --- a/docs/source/api/Exception/Socket/NoConnectionException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception\\Socket** - -===================== -NoConnectionException -===================== - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception\Socket -.. php:exception:: NoConnectionException diff --git a/docs/source/api/Exception/Socket/PackageNotReceivedException.rst b/docs/source/api/Exception/Socket/PackageNotReceivedException.rst deleted file mode 100644 index 095a2a7..0000000 --- a/docs/source/api/Exception/Socket/PackageNotReceivedException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception\\Socket** - -=========================== -PackageNotReceivedException -=========================== - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception\Socket -.. php:exception:: PackageNotReceivedException diff --git a/docs/source/api/Exception/Socket/PackageNotSentException.rst b/docs/source/api/Exception/Socket/PackageNotSentException.rst deleted file mode 100644 index 72a69bb..0000000 --- a/docs/source/api/Exception/Socket/PackageNotSentException.rst +++ /dev/null @@ -1,8 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception\\Socket** - -======================= -PackageNotSentException -======================= - -.. php:namespace:: D3strukt0r\Votifier\Client\Exception\Socket -.. php:exception:: PackageNotSentException diff --git a/docs/source/api/Exception/Socket/index.rst b/docs/source/api/Exception/Socket/index.rst deleted file mode 100644 index df2b09d..0000000 --- a/docs/source/api/Exception/Socket/index.rst +++ /dev/null @@ -1,14 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Exception** - -======== -Socket\\ -======== - -**Interfaces, Classes and Traits** - -.. toctree:: - :maxdepth: 1 - - NoConnectionException - PackageNotReceivedException - PackageNotSentException diff --git a/docs/source/api/Exception/index.rst b/docs/source/api/Exception/index.rst deleted file mode 100644 index 6b06b85..0000000 --- a/docs/source/api/Exception/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client** - -=========== -Exception\\ -=========== - -**Namespaces** - -.. toctree:: - :maxdepth: 1 - - Socket/index - -**Interfaces, Classes and Traits** - -.. toctree:: - :maxdepth: 1 - - NotVotifierException - NuVotifierChallengeInvalidException - NuVotifierException - NuVotifierSignatureInvalidException - NuVotifierUnknownServiceException - NuVotifierUsernameTooLongException diff --git a/docs/source/api/Server/GenericServer.rst b/docs/source/api/Server/GenericServer.rst deleted file mode 100644 index ed2904f..0000000 --- a/docs/source/api/Server/GenericServer.rst +++ /dev/null @@ -1,82 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Server** - -============= -GenericServer -============= - -.. php:namespace:: D3strukt0r\Votifier\Client\Server -.. php:class:: GenericServer - - An abstract class that has all the important functions included for every server. - - .. php:attr:: protected $socket - - :php:class:`D3strukt0r\\Votifier\\Client\\Socket` — The socket object - - .. php:attr:: protected $host - - string — The domain or ip to connect to Votifier - - .. php:attr:: protected $port - - int — The port which votifier uses on the server - - .. php:attr:: protected $publicKey - - string — The public.key which is generated by the plugin - - .. php:method:: public getSocket() -> Socket - - Gets the Socket. - - :returns: :php:class:`D3strukt0r\\Votifier\\Client\\Socket` — Returns a Socket object - - .. php:method:: public setSocket($socket) -> $this - - Sets the Socket. - - :param string $socket: The socket object - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getHost() -> string|null - - Gets the host. - - :returns: string|null — Returns the host - - .. php:method:: public setHost($host) -> $this - - Sets the host. - - :param string $host: The host - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getPort() -> int - - Gets the port. - - :returns: int — Returns the port - - .. php:method:: public setPort($port) -> $this - - Sets the port. - - :param int $port: The port - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getPublicKey() -> string|null - - Gets the public key. - - :returns: string|null — Returns the public key - - .. php:method:: public setPublicKey($publicKey) -> $this - - Sets the public key. - - :param string $publicKey: The public key - - :returns: $this — Returns the class itself, for doing multiple things at once diff --git a/docs/source/api/Server/NuVotifier.rst b/docs/source/api/Server/NuVotifier.rst deleted file mode 100644 index 1e43cfd..0000000 --- a/docs/source/api/Server/NuVotifier.rst +++ /dev/null @@ -1,219 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Server** - -========== -NuVotifier -========== - -.. php:namespace:: D3strukt0r\Votifier\Client\Server -.. php:class:: NuVotifier - - The Class to access a server which uses the plugin "NuVotifier". - - .. php:attr:: protected $socket - - :php:class:`D3strukt0r\\Votifier\\Client\\Socket` — The socket object - - .. php:attr:: protected $host - - string — The domain or ip to connect to Votifier - - .. php:attr:: protected $port - - int — The port which votifier uses on the server - - .. php:attr:: protected $publicKey - - string — The public.key which is generated by the plugin - - .. php:attr:: protected $protocolV2 - - bool — Use version 2 of the protocol - - .. php:attr:: protected $token - - string|null — The token from the config.yml - - .. php:method:: public getSocket() -> Socket - - Gets the Socket. - - :returns: :php:class:`D3strukt0r\\Votifier\\Client\\Socket` — Returns a Socket object - - .. php:method:: public setSocket($socket) -> $this - - Sets the Socket. - - :param string $socket: The socket object - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getHost() -> string|null - - Gets the host. - - :returns: string|null — Returns the host - - .. php:method:: public setHost($host) -> $this - - Sets the host. - - :param string $host: The host - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getPort() -> int - - Gets the port. - - :returns: int — Returns the port - - .. php:method:: public setPort($port) -> $this - - Sets the port. - - :param int $port: The port - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getPublicKey() -> string|null - - Gets the public key. - - :returns: string|null — Returns the public key - - .. php:method:: public setPublicKey($publicKey) -> $this - - Sets the public key. - - :param string $publicKey: The public key - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public isProtocolV2() -> bool - - Checks whether the connection uses the version 2 protocol. - - :returns: bool — Returns true, if using the new version of NuVotifier or false otherwise - - .. php:method:: public setProtocolV2($isProtocolV2) -> $this - - Sets whether to use version 2 of the protocol. - - :param bool $isProtocolV2: Whether to use version 2 of the protocol - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getToken() -> string|null - - Gets the token from the config.yml. - - :returns: string|null — Returns The token from the config.yml - - .. php:method:: public setToken($token) -> $this - - Sets the token from the config.yml. - - :param string|null $token: The token from the config.yml - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public verifyConnection() - - Checks if the server actually belongs to Votifier. - - :throws: :php:exc:`InvalidArgumentException` - - If one required parameter wasn't set - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` - - If connection couldn't be established - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotReceivedException` - - If there was an error receiving the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NotVotifierException` - - If the server we are connected to is not a valid Votifier server - - .. php:method:: public sendVote(...$votes) - - Sends the vote packages to the server. - - :param \\D3strukt0r\\Votifier\\Client\\Vote\\VoteInterface $votes: The vote packages - - :throws: :php:exc:`InvalidArgumentException` - - If one required parameter wasn't set - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` - - If connection couldn't be established - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotSentException` - - If there was an error receiving the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotReceivedException` - - If there was an error sending the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NotVotifierException` - - If the server we are connected to is not a valid Votifier server - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NuVotifierException` - - General NuVotifier Exception (an unknown exception) - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NuVotifierChallengeInvalidException` - - NuVotifier says the challenge was invalid - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NuVotifierSignatureInvalidException` - - NuVotifier says the signature was invalid - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NuVotifierUnknownServiceException` - - NuVotifier says that the service is unknown (the token doesn't belong to the service name) - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NuVotifierUsernameTooLongException` - - NuVotifier says the username is too long - - .. php:method:: protected checkRequiredVariablesForPackage($vote) - - Check that service name, username, address, timestamp and token have been set. - - :param D3strukt0r\\Votifier\\Client\\Vote\\VoteInterface $vote: The vote to check - - :throws: :php:exc:`InvalidArgumentException` - - If one required parameter wasn't set - - .. php:method:: protected verifyConnection($header) -> bool - - Verifies that the connection is correct. - - :param string|null $header: The header that the plugin usually sends - - :returns: bool — Returns true if connections is available, otherwise false - - .. php:method:: protected preparePackage($vote) -> string - - Create encrypted package for default Votifier. - - :param \\D3strukt0r\\Votifier\\Client\\Vote\\VoteInterface $vote: The vote package with all the information - - :returns: string — Returns the string to be sent to the server - - .. php:method:: protected preparePackageV2($vote, $challenge) -> string - - Prepares the vote package to be sent as version 2 protocol package. - - :param D3strukt0r\\Votifier\\Client\\Vote\\VoteInterface $vote: The vote package with information - :param string $challenge: The challenge sent by the server - - :returns: string — Returns the string to be sent to the server diff --git a/docs/source/api/Server/ServerInterface.rst b/docs/source/api/Server/ServerInterface.rst deleted file mode 100644 index 822d4ae..0000000 --- a/docs/source/api/Server/ServerInterface.rst +++ /dev/null @@ -1,98 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Server** - -=============== -ServerInterface -=============== - -.. php:namespace:: D3strukt0r\Votifier\Client\Server -.. php:interface:: ServerInterface - - The interface ServerInterface is used to define a PluginType on the server. - - .. php:method:: public getHost() -> string|null - - Gets the host. - - :returns: string|null — Returns the host - - .. php:method:: public setHost($host) - - Sets the host. - - :param string $host: The host - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getPort() -> int - - Gets the port. - - :returns: int — Returns the port - - .. php:method:: public setPort($port) - - Sets the port. - - :param int $port: The port - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getPublicKey() -> string|null - - Gets the public key. - - :returns: string|null — Returns the public key - - .. php:method:: public setPublicKey($publicKey) - - Sets the public key. - - :param string $publicKey: The public key - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public verifyConnection() - - Checks if the server actually belongs to Votifier. - - :throws: :php:exc:`InvalidArgumentException` - - If one required parameter wasn't set - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` - - If connection couldn't be established - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotReceivedException` - - If there was an error receiving the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NotVotifierException` - - If the server we are connected to is not a valid Votifier server - - .. php:method:: public sendVote(...$votes) - - Sends the vote packages to the server. - - :param D3strukt0r\\Votifier\\Client\\Vote\\VoteInterface $votes: The vote packages - - :throws: :php:exc:`InvalidArgumentException` - - If one required parameter wasn't set - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` - - If connection couldn't be established - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotReceivedException` - - If there was an error receiving the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotSentException` - - If there was an error sending the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NotVotifierException` - - If the server we are connected to is not a valid Votifier server diff --git a/docs/source/api/Server/Votifier.rst b/docs/source/api/Server/Votifier.rst deleted file mode 100644 index c0debdd..0000000 --- a/docs/source/api/Server/Votifier.rst +++ /dev/null @@ -1,158 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Server** - -======== -Votifier -======== - -.. php:namespace:: D3strukt0r\Votifier\Client\Server -.. php:class:: Votifier - - The Class to access a server which uses the classic "Votifier" plugin. - - .. php:attr:: protected $socket - - :php:class:`D3strukt0r\\Votifier\\Client\\Socket` — The socket object - - .. php:attr:: protected $host - - string — The domain or ip to connect to Votifier - - .. php:attr:: protected $port - - int — The port which votifier uses on the server - - .. php:attr:: protected $publicKey - - string — The public.key which is generated by the plugin - - .. php:method:: public getSocket() -> Socket - - Gets the Socket. - - :returns: :php:class:`D3strukt0r\\Votifier\\Client\\Socket` — Returns a Socket object - - .. php:method:: public setSocket($socket) -> $this - - Sets the Socket. - - :param string $socket: The socket object - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getHost() -> string|null - - Gets the host. - - :returns: string|null — Returns the host - - .. php:method:: public setHost($host) -> $this - - Sets the host. - - :param string $host: The host - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getPort() -> int - - Gets the port. - - :returns: int — Returns the port - - .. php:method:: public setPort($port) -> $this - - Sets the port. - - :param int $port: The port - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getPublicKey() -> string|null - - Gets the public key. - - :returns: string|null — Returns the public key - - .. php:method:: public setPublicKey($publicKey) -> $this - - Sets the public key. - - :param string $publicKey: The public key - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public verifyConnection() - - Checks if the server actually belongs to Votifier. - - :throws: :php:exc:`InvalidArgumentException` - - If one required parameter wasn't set - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` - - If connection couldn't be established - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotReceivedException` - - If there was an error receiving the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NotVotifierException` - - If the server we are connected to is not a valid Votifier server - - .. php:method:: public sendVote(...$votes) - - Sends the vote packages to the server. - - :param \\D3strukt0r\\Votifier\\Client\\Vote\\VoteInterface $votes: The vote packages - - :throws: :php:exc:`InvalidArgumentException` - - If one required parameter wasn't set - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` - - If connection couldn't be established - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotSentException` - - If there was an error receiving the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotReceivedException` - - If there was an error sending the package - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\NotVotifierException` - - If the server we are connected to is not a valid Votifier server - - .. php:method:: protected checkRequiredVariablesForSocket() - - Check that both host and port have been set. - - :throws: :php:exc:`InvalidArgumentException` — If one required parameter wasn't set - - .. php:method:: protected checkRequiredVariablesForPackage($vote) - - Check that service name, username, address, timestamp and public key have been set. - - :param D3strukt0r\\Votifier\\Client\\Vote\\VoteInterface $vote: The vote to check - - :throws: :php:exc:`InvalidArgumentException` — If one required parameter wasn't set - - .. php:method:: protected verifyConnection($header) -> bool - - Verifies that the connection is correct. - - :param string|null $header: The header that the plugin usually sends - - :returns: bool — Returns true if connections is available, otherwise false - - .. php:method:: protected preparePackage($vote) -> string - - Create encrypted package for default Votifier. - - :param \\D3strukt0r\\Votifier\\Client\\Vote\\VoteInterface $vote: The vote package with all the information - - :returns: string — Returns the string to be sent to the server diff --git a/docs/source/api/Server/index.rst b/docs/source/api/Server/index.rst deleted file mode 100644 index 5aeafa0..0000000 --- a/docs/source/api/Server/index.rst +++ /dev/null @@ -1,21 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client** - -======== -Server\\ -======== - -**Interfaces** - -.. toctree:: - :maxdepth: 1 - - ServerInterface - -**Interfaces, Classes and Traits** - -.. toctree:: - :maxdepth: 1 - - GenericServer - Votifier - NuVotifier diff --git a/docs/source/api/Socket.rst b/docs/source/api/Socket.rst deleted file mode 100644 index aee63a2..0000000 --- a/docs/source/api/Socket.rst +++ /dev/null @@ -1,47 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client** - -====== -Socket -====== - -.. php:namespace:: D3strukt0r\Votifier\Client -.. php:class:: Socket - - The class ServerConnection is used to create a connection to a server. - - .. php:attr:: private $socket - - resource — The connection to the server - - .. php:method:: public __destruct() - - Closes the connection when the object is destroyed. - - .. php:method:: public open($host, $port) - - Creates the ServerConnection object. - - :param string $host: The hostname or IP address - :param int $port: The port of Votifier - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` — If connection couldn't be established - - .. php:method:: public write($string) - - Sends a string to the server. - - :param string $string: The string which should be sent to the server - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` — If connection has not been set up - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotSentException` — If there was an error sending the package - - .. php:method:: public read([$length = 64]) -> string - - Reads a string which is being received from the server. - - :param int $length: [optional] The length of the requested string - - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\NoConnectionException` — If connection has not been set up - :throws: :php:exc:`D3strukt0r\\Votifier\\Client\\Exception\\Socket\\PackageNotReceivedException` — If there was an error receiving the package - - :returns: string — Returns the string received from the server diff --git a/docs/source/api/Vote/ClassicVote.rst b/docs/source/api/Vote/ClassicVote.rst deleted file mode 100644 index 3499ad7..0000000 --- a/docs/source/api/Vote/ClassicVote.rst +++ /dev/null @@ -1,82 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\Vote** - -=========== -ClassicVote -=========== - -.. php:namespace:: D3strukt0r\Votifier\Client\Vote -.. php:class:: ClassicVote - - The classic vote package can be used by most plugins. - - .. php:attr:: protected $serviceName - - string — The name of the list/service - - .. php:attr:: protected $username - - string — The username who wants to receive the rewards - - .. php:attr:: protected $address - - string — The IP Address of the user - - .. php:attr:: protected $timestamp - - :php:class:`DateTime` — The time when the vote will be sent - - .. php:method:: public getServiceName() -> string|null - - The name of the list/service. - - :returns: string|null — Returns the name of the list/service - - .. php:method:: public setServiceName($serviceName) -> $this - - Sets the name of the list/service. - - :param string $serviceName: The name of the list/service - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getUsername() -> string|null - - Gets the username of the user who wants to receive the rewards. - - :returns: string|null — Returns the username who wants to receive the rewards - - .. php:method:: public setUsername($username) -> $this - - Sets the username of the user who wants to receive the rewards. - - :param string $username: The username of the user who wants to receive the rewards - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getAddress() -> string - - Gets the IP Address of the user. - - :returns: string — Returns the IP Address of the user - - .. php:method:: public setAddress($address) -> $this - - Sets the IP Address of the user. - - :param string $address: The IP address the user is sending a request from - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getTimestamp() -> int|null - - Gets the time when the vote was sent. - - :returns: int|null — Returns the time when the vote was sent, null otherwise - - .. php:method:: public setTimestamp([$timestamp = null]) -> $this - - Sets the time when the vote will be sent. - - :param DateTime|null $timestamp: [optional] Either give a wanted timestamp or it will use the current time - - :returns: $this — Returns the class itself, for doing multiple things at once diff --git a/docs/source/api/Vote/VoteInterface.rst b/docs/source/api/Vote/VoteInterface.rst deleted file mode 100644 index 2c02438..0000000 --- a/docs/source/api/Vote/VoteInterface.rst +++ /dev/null @@ -1,66 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client\\VoteType** - -============= -VoteInterface -============= - -.. php:namespace:: D3strukt0r\Votifier\Client\VoteType -.. php:interface:: VoteInterface - - The interface VoteInterface will be used for different kinds of vote packages. - - .. php:method:: public getServiceName() -> string|null - - The name of the list/service. - - :returns: string|null — Returns the name of the list/service - - .. php:method:: public setServiceName($serviceName) - - Sets the name of the list/service. - - :param string $serviceName: The name of the list/service - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getUsername() -> string|null - - Gets the username of the user who wants to receive the rewards. - - :returns: string|null — Returns the username who wants to receive the rewards - - .. php:method:: public setUsername($username) - - Sets the username of the user who wants to receive the rewards. - - :param string $username: The username of the user who wants to receive the rewards - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getAddress() -> string - - Gets the IP Address of the user. - - :returns: string — Returns the IP Address of the user - - .. php:method:: public setAddress($address) - - Sets the IP Address of the user. - - :param string $address: The IP address the user is sending a request from - - :returns: $this — Returns the class itself, for doing multiple things at once - - .. php:method:: public getTimestamp() -> int|null - - Gets the time when the vote was sent. - - :returns: int|null — Returns the time when the vote was sent, null otherwise - - .. php:method:: public setTimestamp([$timestamp = null]) - - Sets the time when the vote will be sent. - - :param DateTime|null $timestamp: [optional] Either give a wanted timestamp or it will use the current time - - :returns: $this — Returns the class itself, for doing multiple things at once diff --git a/docs/source/api/Vote/index.rst b/docs/source/api/Vote/index.rst deleted file mode 100644 index 51fb2ec..0000000 --- a/docs/source/api/Vote/index.rst +++ /dev/null @@ -1,13 +0,0 @@ -**\\D3strukt0r\\Votifier\\Client** - -====== -Vote\\ -====== - -**Interfaces, Classes and Traits** - -.. toctree:: - :maxdepth: 1 - - VoteInterface - ClassicVote diff --git a/docs/source/api/index.rst b/docs/source/api/index.rst index f9a2e55..ddbf2d3 100644 --- a/docs/source/api/index.rst +++ b/docs/source/api/index.rst @@ -1,19 +1,14 @@ -================================ -\\D3strukt0r\\Votifier\\Client\\ -================================ +============= +API Reference +============= -**Namespaces** +There is no hand-maintained API reference here. Every class, method and +parameter in the library is documented with PHPDoc directly in the source, so +the source is the single, always-up-to-date reference. -.. toctree:: - :maxdepth: 1 +If you are interested in the API, read the source code: - Exception/index - Server/index - Vote/index +`Browse the source on GitHub `_ -**Interfaces, Classes and Traits** - -.. toctree:: - :maxdepth: 1 - - Socket +For practical usage, see the :doc:`Getting Started <../getting-started/votifier>` +section. diff --git a/docs/source/appendix/changelog.rst b/docs/source/appendix/changelog.rst index dfba06c..4a57ee2 100644 --- a/docs/source/appendix/changelog.rst +++ b/docs/source/appendix/changelog.rst @@ -1,59 +1,5 @@ -========= -Changelog -========= +.. Pulled from the root CHANGELOG.md so the documentation and the repository + changelog never drift apart. -3.0.0 -===== -- :code:`Added` :code:`verifyConnection` function to server, to check the server separately. You can figure out if the server is from Votifier before sending a vote -- :code:`Added` php compatibility check for code style check -- :code:`Added` Added setter methods to servers and and votes in place of constructor -- :code:`Added` exceptions for all possible errors (instead of the old Messages class) -- :code:`Dropped` assigning variables in the constructor -- :code:`Dropped` :code:`Messages` class -- :code:`Moved` namespace to :code:`D3strukt0r\Votifier\Client\Server` -- :code:`Fixed` composer not ignoring unnecessary files -- :code:`Fixed` coverage reports -- :code:`Fixed` coding style -- :code:`Updated` the docs - -2.1.2 -===== -Nothing changed in the code, only improved CI and fixed Coverage report - -2.1.1 -===== -- :code:`Added` more documentation using "Read the Docs" -- :code:`Fixed` Bug `#1 `_ - -2.1.0 -===== -- :code:`Added` some required PHP libraries -- :code:`Dropped` compatibility with depreciated PHP versions. Now PHP 7.1+ is required -- :code:`Fixed` Travis tests -- :code:`Fixed` coding style -- :code:`Updated` the docs - -TODO ----- -- :code:`Add` more tests - -2.0.0 -===== -- :code:`Added` server types (to use with different plugins) (Currently: Votifier/NuVotifier) -- :code:`Added` vote types, in case different package types are needed. -- :code:`Added` API Docs using phpDocumentor - -Notes ------ -Anyone who thinks a new ServerType is needed can open an issue and I'll add it to a minor release. -I already tested Votifier/NuVotifier protocol v1/NuVotifier protocol v2 manually and it worked - -1.0.0 -===== -- :code:`Added` coveralls -- :code:`Removed` unnecessary code -- :code:`Fixed` code style - -0.0.1-beta -========== -Begin project +.. include:: ../../../CHANGELOG.md + :parser: myst_parser.docutils_ diff --git a/docs/source/appendix/code-of-conduct.rst b/docs/source/appendix/code-of-conduct.rst index 7bfb6d7..27f21f1 100644 --- a/docs/source/appendix/code-of-conduct.rst +++ b/docs/source/appendix/code-of-conduct.rst @@ -1,51 +1,5 @@ -=============== -Code of conduct -=============== +.. Pulled from the central Team-MaRo/.github repo (the docs/source/_community + submodule) so it is never duplicated or out of date here. -Our Pledge -========== - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -Our Standards -============= - -Examples of behavior that contributes to creating a positive environment include: - -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -- The use of sexualized language or imagery and unwelcome sexual attention or advances -- Trolling, insulting/derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or electronic address, without explicit permission -- Other conduct which could reasonably be considered inappropriate in a professional setting - -Our Responsibilities -==================== - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -Scope -===== - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -Enforcement -=========== - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at manuele.vaccari@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -Attribution -=========== - -This Code of Conduct is adapted from the `Contributor Covenant `_, version 1.4, available at http://contributor-covenant.org/version/1/4/ +.. include:: ../_community/CODE_OF_CONDUCT.md + :parser: myst_parser.docutils_ diff --git a/docs/source/appendix/contributing.rst b/docs/source/appendix/contributing.rst index c4120dc..277eb23 100644 --- a/docs/source/appendix/contributing.rst +++ b/docs/source/appendix/contributing.rst @@ -1,14 +1,27 @@ -============ -Contributing -============ +.. Pulled from the central Team-MaRo/.github repo (the docs/source/_community + submodule) so it is never duplicated or out of date here. -When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change. +.. include:: ../_community/CONTRIBUTING.md + :parser: myst_parser.docutils_ -Please note we have a code of conduct, please follow it in all your interactions with the project. +Code style guidelines +===================== -.. toctree:: - :maxdepth: 2 +This project enforces two complementary code-style tools, both run by CI — make +sure both pass before opening a pull request. - contributing/ways-to-contribute - contributing/pull-request-workflow - contributing/code-style-guidelines +**PHP_CodeSniffer** checks PSR-12 and PHP version compatibility (configured in +``.phpcs.xml``): + +.. code-block:: bash + + composer check # report problems (alias for: ./vendor/bin/phpcs) + composer fix # auto-fix them (alias for: ./vendor/bin/phpcbf) + +**PHP-CS-Fixer** applies the project's coding standard (configured in +``.php-cs-fixer.dist.php``): + +.. code-block:: bash + + composer cs # show the diff without changing files + composer cs:fix # apply the fixes diff --git a/docs/source/appendix/contributing/code-style-guidelines.rst b/docs/source/appendix/contributing/code-style-guidelines.rst deleted file mode 100644 index 24d2be3..0000000 --- a/docs/source/appendix/contributing/code-style-guidelines.rst +++ /dev/null @@ -1,33 +0,0 @@ -===================== -Code style guidelines -===================== - -This project has CodeSniffer as a dependency. So before creating a pull-request, make sure it doesn't show any warnings. The CI will test this too. You can try in two ways. - -.. code-block:: bash - - ./vendor/bin/phpcs - -.. code-block:: bash - - composer run-script check - -And to fix it with :code:`phpcbf` you can run it with - -.. code-block:: bash - - ./vendor/bin/phpcbf - -.. code-block:: bash - - composer run-script fix - -PHP-CS-Fixer is also installed, but because it's impossible to set it up to support PSR-12, I have removed it from being a requirement and left it as just "for information". You can try it anyways. - -.. code-block:: bash - - ./vendor/bin/php-cs-fixer - -.. code-block:: bash - - composer run-script check2 diff --git a/docs/source/appendix/contributing/pull-request-workflow.rst b/docs/source/appendix/contributing/pull-request-workflow.rst deleted file mode 100644 index 9fb3023..0000000 --- a/docs/source/appendix/contributing/pull-request-workflow.rst +++ /dev/null @@ -1,8 +0,0 @@ -===================== -Pull request workflow -===================== - -1. Ensure any install or build dependencies are removed before the end of the layer when doing a build. -2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters. -3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is `SemVer `_. -4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you. diff --git a/docs/source/appendix/contributing/ways-to-contribute.rst b/docs/source/appendix/contributing/ways-to-contribute.rst deleted file mode 100644 index b870afb..0000000 --- a/docs/source/appendix/contributing/ways-to-contribute.rst +++ /dev/null @@ -1,7 +0,0 @@ -================== -Ways to contribute -================== - -- Contribute with code on Github -- Donate some money to support my life basically (Links can be found on the Github project page) -- Tell people who could be interested about this library diff --git a/docs/source/appendix/copyright.rst b/docs/source/appendix/copyright.rst index 004ea49..8a85d0e 100644 --- a/docs/source/appendix/copyright.rst +++ b/docs/source/appendix/copyright.rst @@ -1,148 +1,34 @@ -.. role:: bold-italic - :class: bold-italic -.. role:: underline - :class: underline - ========= Copyright ========= -*Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.* - -:bold-italic:`Using Creative Commons Public Licenses` - -Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. - -:bold-italic:`Considerations for licensors:` Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. `More considerations for licensors. `_ - -:bold-italic:`Considerations for the public`: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. `More considerations for the public. `_ - -Creative Commons Attribution-ShareAlike 4.0 International Public License -======================================================================== -By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. - -Section 1 – Definitions. ------------------------- - -a. **Adapted Material** means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. -b. **Adapter's License** means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. -c. **BY-SA Compatible License** means a license listed at `creativecommons.org/compatiblelicenses `_, approved by Creative Commons as essentially the equivalent of this Public License. -d. **Copyright and Similar Rights** means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. -e. **Effective Technological Measures** means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. -f. **Exceptions and Limitations** means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. -g. **License Elements** means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. -h. **Licensed Material** means the artistic or literary work, database, or other material to which the Licensor applied this Public License. -i. **Licensed Rights** means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. -j. **Licensor** means the individual(s) or entity(ies) granting rights under this Public License. -k. **Share** means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. -l. **Sui Generis Database Rights** means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. -m. **You** means the individual or entity exercising the Licensed Rights under this Public License. **Your** has a corresponding meaning. - -Section 2 – Scope. ------------------- - -a. **License grant.** - - 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: - - A. reproduce and Share the Licensed Material, in whole or in part; and - B. produce, reproduce, and Share Adapted Material. - - 2. :underline:`Exceptions and Limitations`. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. - 3. :underline:`Term`. The term of this Public License is specified in Section 6(a). - 4. :underline:`Media and formats; technical modifications allowed`. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. - 5. :underline:`Downstream recipients`. - - A. :underline:`Offer from the Licensor – Licensed Material`. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. - B. :underline:`Additional offer from the Licensor – Adapted Material`. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. - C. :underline:`No downstream restrictions`. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. - - 6. :underline:`No endorsement`. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). -b. **Other rights.** - - 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. - 2. Patent and trademark rights are not licensed under this Public License. - 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. - -Section 3 – License Conditions. -------------------------------- - -Your exercise of the Licensed Rights is expressly made subject to the following conditions. - -a. **Attribution.** - - 1. If You Share the Licensed Material (including in modified form), You must: - - A. retain the following if it is supplied by the Licensor with the Licensed Material: - - i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); - ii. a copyright notice; - iii. a notice that refers to this Public License; - iv. a notice that refers to the disclaimer of warranties; - v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; - - B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and - C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. - - 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. - 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. - -b. **ShareAlike.** - - In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. - - 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. - 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. - 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. - -Section 4 – Sui Generis Database Rights. ----------------------------------------- - -Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: - -a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; -b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and -c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. - -For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. - -Section 5 – Disclaimer of Warranties and Limitation of Liability. ------------------------------------------------------------------ - -a. **Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.** -b. **To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.** -c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. - -Section 6 – Term and Termination. ---------------------------------- - -a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. -b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: - - 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or - 2. upon express reinstatement by the Licensor. - - For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. - -c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. -d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. +The **source code** of this project is licensed under the MIT License (see +``LICENSE.txt`` in the repository root). -Section 7 – Other Terms and Conditions. ---------------------------------------- +This **documentation** is licensed under +`Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) +`_. -a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. -b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. +.. raw:: html -Section 8 – Interpretation. ---------------------------- +

+ This work is licensed under + Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International + + + + +

-a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. -b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. -c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. -d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. +The plain-text original is kept at ``docs/LICENSE.txt``; the formatted text below +is reproduced from it. -Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the `CC0 Public Domain Dedication `_. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at `creativecommons.org/policies `_, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. +.. note:: -Creative Commons may be contacted at `creativecommons.org `_. + The license text below is generated by ``docs/update-license.py`` from the + official `creativecommons.org legalcode + `_ (falling back + to ``docs/LICENSE.txt`` if offline) — reformatted to reStructuredText, with + the wording kept verbatim. -Additional languages available: `العربية `_, `čeština `_, `Deutsch `_, `Ελληνικά `_, `Español `_, `euskara `_, `suomeksi `_, `français `_, `hrvatski `_, `Bahasa Indonesia `_, `italiano `_, `日本語 `_, `한국어 `_, `Lietuvių `_, `latviski `_, `te reo Māori `_, `Nederlands `_, `norsk `_, `polski `_, `português `_, `română `_, `русский `_, `Slovenščina `_, `svenska `_, `Türkçe `_, `українська `_, `中文 `_, `華語 `_. Please read the `FAQ `_ for more information about official translations. +.. include:: ../../LICENSE.rst diff --git a/docs/source/appendix/faq.rst b/docs/source/appendix/faq.rst deleted file mode 100644 index 2a9c336..0000000 --- a/docs/source/appendix/faq.rst +++ /dev/null @@ -1,5 +0,0 @@ -================================ -FAQ (Frequently Asked Questions) -================================ - -Start asking question, or this never gets created. diff --git a/docs/source/appendix/sponsors.rst b/docs/source/appendix/sponsors.rst deleted file mode 100644 index b2f19f1..0000000 --- a/docs/source/appendix/sponsors.rst +++ /dev/null @@ -1,5 +0,0 @@ -======== -Sponsors -======== - -None (yet) diff --git a/docs/source/conf.py b/docs/source/conf.py index 0dcbfe9..0c359c9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,9 +16,21 @@ # -- Project information ----------------------------------------------------- +import re +from pathlib import Path + project = 'votifier-client-php' -copyright = '2020, Manuele Vaccari' -author = 'Manuele Vaccari' + +# Derive the copyright years and holder from LICENSE.txt (single source of +# truth) so they never have to be hand-updated here. +_license = (Path(__file__).resolve().parents[2] / 'LICENSE.txt').read_text(encoding='utf-8') +_match = re.search(r'Copyright \(c\)\s+([0-9][0-9,\-\s]*[0-9])\s+([A-Za-z].*)', _license) +if _match: + _years, author = _match.group(1).strip(), _match.group(2).strip() +else: # fall back rather than break the build if the license format changes + _years, author = '2015-present', 'Manuele Vaccari' + +copyright = f'{_years} {author}' # The full version, including alpha/beta/rc tags # release = 'x.x.x' @@ -29,7 +41,8 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinxcontrib.phpdomain' + 'sphinxcontrib.phpdomain', + 'myst_parser', ] # Add any paths that contain templates here, relative to this directory. @@ -38,7 +51,9 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['Thumbs.db', '.DS_Store'] +# '_community' is the Team-MaRo/.github submodule — its Markdown files are pulled +# in via `.. include::`, so exclude them from being built as standalone pages. +exclude_patterns = ['Thumbs.db', '.DS_Store', '_community'] # The master toctree document. master_doc = 'index' @@ -53,13 +68,7 @@ # html_theme = 'sphinx_rtd_theme' -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". +# Styles the `:underline:` role used by the generated license (RST has no native +# underline); see docs/source/_static/css/custom.css. html_static_path = ['_static'] - -# These paths are either relative to html_static_path -# or fully qualified paths (eg. https://...) -html_css_files = [ - 'css/custom.css', -] +html_css_files = ['css/custom.css'] diff --git a/docs/source/getting-started/prerequisites.rst b/docs/source/getting-started/prerequisites.rst index febe52a..318ecc1 100644 --- a/docs/source/getting-started/prerequisites.rst +++ b/docs/source/getting-started/prerequisites.rst @@ -34,12 +34,20 @@ We can use a Docker container for this -e EULA=true \ d3strukt0r/spigot -And place the latest and desired Votifier Jar that you want. Out of simplicity let's use the classic one. +Place a Votifier plugin jar in :code:`./spigot/plugins/` and restart the server. -https://dev.bukkit.org/projects/votifier/files/latest +We recommend **NuVotifier** -- it is maintained, runs on current Java, and speaks both the +classic Votifier protocol and its own v2 token protocol: -And put it in :code:`./spigot/plugins/` +- SpigotMC: https://www.spigotmc.org/resources/nuvotifier.13449/ +- GitHub releases: https://github.com/NuVotifier/NuVotifier/releases -After that you can restart the server with the previous command. +.. warning:: + + Avoid the original "classic" vexsoftware Votifier on modern servers: it relies on + ``javax.xml.bind.DatatypeConverter`` (removed from the JDK in Java 11), so it only runs + on Java 8 -- i.e. Minecraft up to 1.16.5. See :doc:`votifier` for the details. For + reference: https://github.com/vexsoftware/votifier and + https://www.curseforge.com/minecraft/bukkit-plugins/votifier Now you have your project with the plugin and a server which runs the votifier plugin. diff --git a/docs/source/getting-started/votifier.rst b/docs/source/getting-started/votifier.rst index e11af4f..867dc4b 100644 --- a/docs/source/getting-started/votifier.rst +++ b/docs/source/getting-started/votifier.rst @@ -4,6 +4,16 @@ Sending a vote to Votifier When you have a server which runs the classic Votifier plugin, you can use this code here. +.. warning:: + + The classic Votifier plugin relies on ``javax.xml.bind.DatatypeConverter``, which + was removed from the JDK in Java 11, so it only runs on Java 8. The newest Minecraft + server that still runs on Java 8 is **1.16.5** (1.17 raised the requirement to Java + 16), which makes 1.16.5 the last version the classic plugin works on. On a newer + server it fails to enable with ``NoClassDefFoundError: javax/xml/bind/DatatypeConverter``. + Prefer :doc:`NuVotifier ` — the maintained successor that runs on current + Java and is backwards compatible with this classic protocol. + You can place following code wherever you want to set up the vote: .. code-block:: php diff --git a/docs/source/index.rst b/docs/source/index.rst index 067efa0..9049ed6 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,7 +2,7 @@ Votifier Client (PHP) Manual ============================ -This work is licensed under a `Creative Commons Attribution-ShareAlike 4.0 International License `_. +This work is licensed under `Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International `_ (see :doc:`appendix/copyright`). Table of content ================ @@ -29,8 +29,6 @@ Table of content :numbered: 1 appendix/story - appendix/sponsors - appendix/faq appendix/changelog appendix/contributing appendix/code-of-conduct diff --git a/docs/update-license.py b/docs/update-license.py new file mode 100755 index 0000000..242c812 --- /dev/null +++ b/docs/update-license.py @@ -0,0 +1,276 @@ +#!/usr/bin/env python3 +# /// script +# requires-python = ">=3.8" +# dependencies = ["beautifulsoup4"] +# /// +"""Regenerate docs/LICENSE.rst (CC BY-NC-SA 4.0) for the documentation. + +Primary source: the official HTML legalcode on creativecommons.org, converted to +reStructuredText so the lettered/roman/numbered lists (a. / i. / A. / 1.) render +natively, with underlined defined terms, bold and hyperlinks preserved. + +Fallback: if the site can't be reached, the committed plain-text legalcode +(docs/LICENSE.txt) is converted instead — same structure and lists, but without +the underline/bold that only exist in the HTML. + +Run: uv run docs/update-license.py (RTD runs it in a pre_build job) +""" +import re +import string +import textwrap +import urllib.request +from pathlib import Path +from urllib.error import URLError + +from bs4 import BeautifulSoup, NavigableString + +SOURCE_URL = "https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode" +HERE = Path(__file__).resolve().parent +OUTPUT = HERE / "LICENSE.rst" +LICENSE_TXT = HERE / "LICENSE.txt" +WRAP_WIDTH = 71 +DIVS = ["notice-about-licenses-and-cc", "about-cc-and-license", + "legal-code-body", "notice-about-cc-and-trademark"] +CHROME = {"About the license and Creative Commons", "About Creative Commons"} +# Heading underline characters, from the license's top level downward (they sit +# under copyright.rst's "=" title, so they must be distinct from "="). +HEADING_CHARS = "-~^\"" + +_ROMAN = [(1000, "m"), (900, "cm"), (500, "d"), (400, "cd"), (100, "c"), + (90, "xc"), (50, "l"), (40, "xl"), (10, "x"), (9, "ix"), + (5, "v"), (4, "iv"), (1, "i")] + + +def _alpha(idx): + out, n = "", idx + 1 + while n > 0: + n, r = divmod(n - 1, 26) + out = string.ascii_lowercase[r] + out + return out + + +def _roman(idx): + n, out = idx + 1, "" + for value, sym in _ROMAN: + while n >= value: + out, n = out + sym, n - value + return out + + +def _marker(idx, list_type): + # Always lowercase, matching the plain-text legalcode. + return {"a": _alpha(idx), "i": _roman(idx)}.get((list_type or "1").lower(), str(idx + 1)) + + +def _fix_href(href): + if href.startswith("//"): + href = "https:" + href + elif href.startswith("/"): + href = "https://creativecommons.org" + href + return re.sub( + r"https://wiki\.creativecommons\.org/wiki/Considerations_for_licensors_and_licensees#(Considerations_for_licens\w+)", + r"https://wiki.creativecommons.org/\1", href) + + +# ---- HTML -> RST ----------------------------------------------------------- + +def inline_node(child): + """A single inline node (text or element) as an RST string.""" + if isinstance(child, NavigableString): + return str(child) + name = child.name + if name in ("strong", "b"): + text = inline(child).strip() + return text.upper() if len(text) > 100 else f"**{text}**" + if name in ("em", "i"): + return f"*{inline(child).strip()}*" + if name == "u" or (name == "span" and "underline" in (child.get("style") or "")): + return f":underline:`{inline(child).strip()}`" + if name == "a": + text, href = inline(child).strip(), child.get("href", "") + return text if href.startswith("#") else f"`{text} <{_fix_href(href)}>`__" + return inline(child) + + +def inline(node): + """Inline content of a node's children as an RST string.""" + return re.sub(r"\s+", " ", "".join(inline_node(c) for c in node.children)) + + +def render_list(ol, indent): + items = [c for c in ol.children if getattr(c, "name", None) == "li"] + list_type = ol.get("type", "1") if ol.name == "ol" else None + blocks = [] + for idx, li in enumerate(items): + marker = "- " if list_type is None else _marker(idx, list_type) + ". " + lead, nested = [], [] + for child in li.children: + if getattr(child, "name", None) in ("ol", "ul"): + nested.append(child) + else: + lead.append(inline_node(child)) + lead_text = re.sub(r"\s+", " ", "".join(lead)).strip() + hang = indent + " " * len(marker) + out = textwrap.fill(lead_text, WRAP_WIDTH, initial_indent=indent + marker, + subsequent_indent=hang, break_long_words=False, + break_on_hyphens=False) + for sub in nested: + out += "\n\n" + render_list(sub, hang) + blocks.append(out) + return "\n\n".join(blocks) + + +def heading(text, level): + text = to_ascii(text) # so the underline length matches the final text + return f"{text}\n{HEADING_CHARS[level] * len(text)}" + + +def html_to_rst(html): + soup = BeautifulSoup(html, "html.parser") + out = [] + title = None + for div_id in DIVS: + div = soup.find(id=div_id) + if div is None: + continue + # Walk the div's meaningful blocks in document order. + for node in div.descendants: + name = getattr(node, "name", None) + if name == "h2" and node.get("id") == "legal-code-title": + title = inline(node).strip() + # The formal "... Public License" heading is only inline text in + # the HTML; emit it here (before "By exercising") as a heading. + out.append(("formal", f"Creative Commons {title} Public License")) + elif name in ("h2",) and inline(node).strip() in CHROME: + continue + elif name == "h2": + out.append(("usingcc", inline(node).strip())) + elif name == "h3": + out.append(("section", inline(node).strip())) + elif name == "p" and node.find_parent("li") is None: + out.append(("p", inline(node).strip())) + elif name == "ol" and node.find_parent(["ol", "ul"]) is None: + out.append(("list", node)) + return assemble(title, out, source="html") + + +# ---- plain text -> RST (fallback) ------------------------------------------ + +SEP = re.compile(r"^[=-]{3,}\s*$") +SECTION = re.compile(r"^Section \d+ -- .+\.$") +ITEM = re.compile(r"^(\s*)((?:[A-Za-z]|[ivxlcdmIVXLCDM]+|\d+)\.)\s+(.*)$") + + +def txt_to_rst(text): + out, title = [], None + blocks, cur = [], [] + for line in text.splitlines(): + if not line.strip(): + if cur: + blocks.append(cur) + cur = [] + elif SEP.match(line): + continue + else: + cur.append(line) + if cur: + blocks.append(cur) + + stack = [] # (text_col, rst_indent, marker_width) + first = True + for block in blocks: + joined = " ".join(l.strip() for l in block) + if first: + title = joined + first = False + continue + if joined == "Using Creative Commons Public Licenses": + out.append(("usingcc", joined)); stack = []; continue + if joined.startswith("Creative Commons Attribution") and joined.endswith("Public License"): + out.append(("formal", joined)); stack = []; continue + if len(block) == 1 and SECTION.match(block[0].strip()): + out.append(("section", block[0].strip())); stack = []; continue + m = ITEM.match(block[0]) + if m: + ws, mark, head = m.groups() + text_col = len(ws) + len(mark) + 1 + body = (head + " " + " ".join(l.strip() for l in block[1:])).strip() + body = _linkify(body) + while stack and stack[-1][0] > text_col: + stack.pop() + if stack and stack[-1][0] == text_col: + rst_indent = stack[-1][1]; stack.pop() + elif stack: + rst_indent = stack[-1][1] + stack[-1][2] + else: + rst_indent = 0 + mw = len(mark) + 1 + stack.append((text_col, rst_indent, mw)) + pad = " " * rst_indent + out.append(("li", textwrap.fill( + mark + " " + body, WRAP_WIDTH, initial_indent=pad, + subsequent_indent=pad + " " * mw, + break_long_words=False, break_on_hyphens=False))) + else: + out.append(("p", _linkify(joined))); stack = [] + return assemble(title, out, source="txt") + + +def _linkify(text): + text = re.sub(r"\b((?:wiki\.)?creativecommons\.org/[A-Za-z0-9/_-]+)", + r"`\1 `__", text) + return re.sub(r"(?`__", text) + + +# ---- shared assembly ------------------------------------------------------- + +def assemble(title, items, source): + lines = [".. role:: underline", ""] + if title: + lines += [heading(title, 0), ""] + for kind, value in items: + if kind == "usingcc": + lines += [heading(value, 1), ""] + elif kind == "formal": + lines += [heading(value, 1), ""] + elif kind == "section": + lines += [heading(value, 2), ""] + elif kind == "p": + lines += [textwrap.fill(value, WRAP_WIDTH, break_long_words=False, + break_on_hyphens=False), ""] + elif kind == "li": # txt fallback: already-rendered RST list block + lines += [value, ""] + elif kind == "list": # html: a bs4
    + lines += [render_list(value, ""), ""] + # For the HTML source, lift the formal "... Public License" heading to sit + # before "By exercising" (it's only inline text in the HTML); the txt has it. + rst = "\n".join(lines) + rst = re.sub(r"\n{3,}", "\n\n", rst).strip() + "\n" + return to_ascii(rst) + + +_TYPOGRAPHY = {"“": '"', "”": '"', "‘": "'", "’": "'", "–": "--", "—": "--"} + + +def to_ascii(text): + for fancy, plain in _TYPOGRAPHY.items(): + text = text.replace(fancy, plain) + return text + + +def main(): + try: + request = urllib.request.Request(SOURCE_URL, headers={"User-Agent": "Mozilla/5.0"}) + html = urllib.request.urlopen(request, timeout=30).read().decode("utf-8") + rst = html_to_rst(html) + src = "official HTML legalcode" + except (URLError, OSError) as exc: + rst = txt_to_rst(LICENSE_TXT.read_text(encoding="utf-8")) + src = f"docs/LICENSE.txt (HTML fetch failed: {exc})" + OUTPUT.write_text(rst, encoding="utf-8") + print(f"Wrote {OUTPUT} from {src} ({len(rst.splitlines())} lines).") + + +if __name__ == "__main__": + main() diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml index ab5df68..6f9cf95 100644 --- a/phpdoc.dist.xml +++ b/phpdoc.dist.xml @@ -1,9 +1,9 @@ - + xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/phpDocumentor/phpDocumentor/refs/tags/v3.10.0/data/xsd/phpdoc.xsd"> Votifier Client api @@ -32,4 +32,4 @@