Hello, how are you ? As I have no knowledge of programming, I asked ChatGPT to create a plugin for ip.board 4 for me, which would detect members who were using adblock and take this to the admin panel, and also display a message to subscribers and members who were using it, so chatgpt provided me with the following 3 files below, however, I don't know how to implement them, could anyone help me?:
Plugin XML:
<plugin>
<title>Detect AdBlock Member and Visitant</title>
<version>1.0.0</version>
<author>Fantasma Verde</author>
<url>https://steamverde.net</url>
<description>Detecta se um membro está usando AdBlock e exibe esta informação no painel de administração. Além disso, exibe uma mensagem no frontend para visitantes e usuários cadastrados que estiverem usando AdBlock, avisando para desativá-lo.</description>
<hooks>
<templateHooks>
<templateHook>
<hookClass>ips_adblockdetector_hook_FrontEnd</hookClass>
<position>footer</position>
</templateHook>
</templateHooks>
<frontEndHooks>
<frontEndHook>
<hookClass>ips_adblockdetector_hook_FrontEnd</hookClass>
<method>detectAdBlock</method>
<location>global</location>
<runOrder>0</runOrder>
</frontEndHook>
</frontEndHooks>
<adminHooks>
<adminHook>
<hookClass>ips_adblockdetector_hook_AdminDashboard</hookClass>
<method>widgets</method>
<location>dashboard</location>
<runOrder>0</runOrder>
</adminHook>
</adminHooks>
</hooks>
<fileHooks>
<fileHook>
<class>ips_adblockdetector_hook_FrontEnd</class>
<method>detectAdBlock</method>
<file>front/front.php</file>
</fileHook>
<fileHook>
<class>ips_adblockdetector_hook_AdminDashboard</class>
<method>widgets</method>
<file>admin/dashboard.php</file>
</fileHook>
</fileHooks>
</plugin>
Frontend File (front/front.php):
<?php
class ips_adblockdetector_hook_FrontEnd extends _HOOK_CLASS_
{
public function detectAdBlock()
{
?>
<script>
// Função para detectar AdBlock
function checkAdBlock() {
var adBlockEnabled = false;
var testAd = document.createElement('div');
testAd.innerHTML = ' ';
testAd.className = 'adblock-test';
document.body.appendChild(testAd);
window.setTimeout(function() {
if (!testAd.offsetHeight) {
adBlockEnabled = true;
// Exiba uma mensagem de aviso para os usuários
alert("Você está usando um bloqueador de anúncios. Por favor, desative-o para acessar o conteúdo.");
}
document.body.removeChild(testAd);
}, 100);
}
// Chamada à função de verificação quando a página é carregada
window.onload = function() {
checkAdBlock();
};
</script>
<?php
}
}
Admin File (admin/dashboard.php):
<?php
use IPS\Db;
class ips_adblockdetector_hook_AdminDashboard extends _HOOK_CLASS_
{
public function widgets()
{
$widgets = parent::widgets();
// Adicione um novo widget ao painel de administração
$widgets['adblock_users'] = [
'title' => 'Usuários com AdBlock',
'content' => $this->getAdblockUsers()
];
return $widgets;
}
// Função para obter usuários com AdBlock
protected function getAdblockUsers()
{
$db = Db::i();
// Execute a consulta para obter usuários com AdBlock ativado
$adblockUsers = $db->select('*', 'core_members', ['adblock' => 1]);
$output = '<ul>';
foreach ($adblockUsers as $user) {
$output .= '<li>' . $user['name'] . '</li>';
}
$output .= '</ul>';
return $output;
}
}