| Server IP : 35.236.43.222 / Your IP : 216.73.216.143 Web Server : Apache System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64 User : deploy ( 1002) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/mastersystem.app/public/wp-content/plugins/koko-analytics/src/ |
Upload File : |
<?php
/**
* @package koko-analytics
* @license GPL-3.0+
* @author Danny van Kooten
*/
namespace KokoAnalytics;
class Plugin
{
public function action_activate_plugin()
{
(new Cron())->setup();
(new Endpoint_Installer())->install();
$this->setup_capabilities();
$this->create_and_protect_uploads_dir();
}
public function action_deactivate_plugin()
{
(new Cron())->clear();
(new Endpoint_Installer())->uninstall();
}
public function setup_capabilities(): void
{
// add capabilities to administrator role (if it exists)
$role = get_role('administrator');
if ($role) {
$role->add_cap('view_koko_analytics');
$role->add_cap('manage_koko_analytics');
}
}
public function create_and_protect_uploads_dir(): void
{
$filename = get_buffer_filename();
$directory = \dirname($filename);
if (! \is_dir($directory)) {
\mkdir($directory, 0755, true);
}
// create empty index.html to prevent directory listing
file_put_contents("$directory/index.html", '');
// create .htaccess in case we're using apache
$lines = [
'<IfModule !authz_core_module>',
'Order deny,allow',
'Deny from all',
'</IfModule>',
'<IfModule authz_core_module>',
'Require all denied',
'</IfModule>',
'',
];
file_put_contents("$directory/.htaccess", join(PHP_EOL, $lines));
}
}