Skip to content

Instantly share code, notes, and snippets.

@event15
Last active March 17, 2020 01:00
Show Gist options
  • Save event15/705acccadc62c7f2e2e0d73be6418879 to your computer and use it in GitHub Desktop.
Save event15/705acccadc62c7f2e2e0d73be6418879 to your computer and use it in GitHub Desktop.
<?php
function qa_get_request_content(): ?array
{
$request = qa_request();
$requestparts = qa_request_parts();
$firstlower = strtolower($requestparts[0]);
$routing = qa_page_routing();
$page = $firstlower . '/';
// todo: to wiadomo, że jest do poprawy, ale tu dalem koncept tylko
if (isset($routing[$page]) && in_array($request, ['messages', 'message/superadmin'])) {
qa_set_template($firstlower !== '' ? $firstlower : 'qa'); // will be changed later
$qa_content = require QA_INCLUDE_DIR . 'pages/default.php';
if (isset($qa_content)) {
qa_set_form_security_key();
}
return $qa_content;
}
return qa_get_request_content_base();
}
<?php
declare(strict_types=1);
class block_pw_page
{
private $directory;
private $urltoroot;
public function load_module(string $directory, string $urltoroot): void
{
$this->directory = $directory;
$this->urltoroot = $urltoroot;
}
public function match_request(string $request): bool
{
return in_array($request, ['messages', 'message/superadmin']);
}
public function process_request(string $request): ?array
{
$qa_content = require QA_INCLUDE_DIR . '/pages/messages.php';
echo "<h1 style='color: red'>just a test</h1>";
return $qa_content;
}
}
{
"name": "Block pw",
"uri": "https://forum.pasja-informatyki.pl",
"description": "Very powerful and useful plugin for blocking pw from unpleasant users :)",
"version": "1.0",
"date": "2020-03-16",
"author": "Mariusz08",
"author_uri": "https://forum.pasja-informatyki.pl/user/Mariusz08",
"license": "GPLv3+",
"min_q2a": "1.5"
}
<?php
/*
Plugin Name: Block pw
Plugin URI: https://forum.pasja-informatyki.pl
Plugin Description: Very powerful and useful plugin for blocking pw from unpleasant users :)
Plugin Version: 1.0
Plugin Date: 2020-03-16
Plugin Author: https://forum.pasja-informatyki.pl/user/Mariusz08
Plugin License: GPLv3
Plugin Minimum Question2Answer Version: 1.7
Plugin Update Check URI:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License for more details.
More about this license: http://www.gnu.org/licenses/gpl.html
*/
if (!defined('QA_VERSION')) {
header('Location: ../../');
exit;
}
qa_register_plugin_module('page', 'block-pw-page.php', block_pw_page::class, 'Block pw page');
qa_register_plugin_overrides('block-pw-override.php');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment