Merge branch 'develop' into fix-phpstan-error-level-0-part2

pull/1577/head
Art4 2024-11-27 22:25:42 +00:00
commit 9cb728d19a
5 changed files with 32 additions and 78 deletions

View File

@ -192,9 +192,30 @@ function advancedcontentfilter_init()
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') { if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') {
$slim = \Slim\Factory\AppFactory::create(); $slim = \Slim\Factory\AppFactory::create();
require __DIR__ . '/src/middlewares.php'; /**
* The routing middleware should be added before the ErrorMiddleware
* Otherwise exceptions thrown from it will not be handled
*/
$slim->addRoutingMiddleware();
$slim->addErrorMiddleware(true, true, true, DI::logger());
// register routes
$slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->get('', 'advancedcontentfilter_get_rules');
$app->post('', 'advancedcontentfilter_post_rules');
$app->get('/{id}', 'advancedcontentfilter_get_rules_id');
$app->put('/{id}', 'advancedcontentfilter_put_rules_id');
$app->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
});
$app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
});
});
require __DIR__ . '/src/routes.php';
$slim->run(); $slim->run();
exit; exit;

View File

@ -1,32 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
use Friendica\DI;
/** @var $slim \Slim\App */
/**
* The routing middleware should be added before the ErrorMiddleware
* Otherwise exceptions thrown from it will not be handled
*/
$slim->addRoutingMiddleware();
$errorMiddleware = $slim->addErrorMiddleware(true, true, true, DI::logger());

View File

@ -1,36 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* @var $slim Slim\App */
$slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->get('', 'advancedcontentfilter_get_rules');
$app->post('', 'advancedcontentfilter_post_rules');
$app->get('/{id}', 'advancedcontentfilter_get_rules_id');
$app->put('/{id}', 'advancedcontentfilter_put_rules_id');
$app->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
});
$app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) {
$app->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
});
});

View File

@ -762,13 +762,13 @@ class CodebirdSN
* @param string $method The API method to call * @param string $method The API method to call
* @param array $params The parameters to send along * @param array $params The parameters to send along
* *
* @return void * @return string
*/ */
protected function _buildMultipart($method, $params) protected function _buildMultipart($method, $params)
{ {
// well, files will only work in multipart methods // well, files will only work in multipart methods
if (! $this->_detectMultipart($method)) { if (! $this->_detectMultipart($method)) {
return; return '';
} }
// only check specific parameters // only check specific parameters
@ -783,7 +783,7 @@ class CodebirdSN
); );
// method might have files? // method might have files?
if (! in_array($method, array_keys($possible_files))) { if (! in_array($method, array_keys($possible_files))) {
return; return '';
} }
$possible_files = explode(' ', $possible_files[$method]); $possible_files = explode(' ', $possible_files[$method]);
@ -794,7 +794,6 @@ class CodebirdSN
// is it an array? // is it an array?
if (is_array($value)) { if (is_array($value)) {
throw new \Exception('Using URL-encoded parameters is not supported for uploading media.'); throw new \Exception('Using URL-encoded parameters is not supported for uploading media.');
continue;
} }
// check for filenames // check for filenames

View File

@ -70,6 +70,7 @@ class tictac {
private $dimen; private $dimen;
private $first_move = true; private $first_move = true;
private $handicap = 0; private $handicap = 0;
private $mefirst;
private $yours; private $yours;
private $mine; private $mine;
private $winning_play; private $winning_play;
@ -163,8 +164,8 @@ class tictac {
function __construct($dimen, $handicap, $mefirst, $yours, $mine) { function __construct($dimen, $handicap, $mefirst, $yours, $mine) {
$this->dimen = 3; $this->dimen = 3;
$this->handicap = (($handicap) ? 1 : 0); $this->handicap = $handicap ? 1 : 0;
$this->mefirst = (($mefirst) ? 1 : 0); $this->mefirst = $mefirst ? 1 : 0;
$this->yours = str_replace('XXX','',$yours); $this->yours = str_replace('XXX','',$yours);
$this->mine = $mine; $this->mine = $mine;
$this->you = $this->parse_moves('you'); $this->you = $this->parse_moves('you');
@ -175,6 +176,7 @@ class tictac {
} }
function play() { function play() {
$o = '';
if($this->first_move) { if($this->first_move) {
if(rand(0,1) == 1) { if(rand(0,1) == 1) {
@ -629,7 +631,7 @@ function winning_move() {
function draw_board() { function draw_board() {
if(! strlen($this->yours)) if(! strlen($this->yours))
$this->yours = 'XXX'; $this->yours = 'XXX';
$o .= "<form action=\"tictac/{$this->handicap}/{$this->mefirst}/{$this->dimen}/{$this->yours}/{$this->mine}\" method=\"post\" />"; $o = "<form action=\"tictac/{$this->handicap}/{$this->mefirst}/{$this->dimen}/{$this->yours}/{$this->mine}\" method=\"post\" />";
for($x = 0; $x < $this->dimen; $x ++) { for($x = 0; $x < $this->dimen; $x ++) {
$o .= '<table>'; $o .= '<table>';
for($y = 0; $y < $this->dimen; $y ++) { for($y = 0; $y < $this->dimen; $y ++) {