use WHMCS\Database\Capsule;
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
function ticketspamcheck_config() {
$authorLink = "https://whmcs.ricardoneud.nl";
return [
'name' => 'Ticket Spam Checker',
'description' => 'Check for spam in ticket submissions based on frequency.',
'version' => '1.1',
'author' => '
<a href="' . $authorLink . '" style="text-decoration: none; display: inline-flex; align-items: center;">
Ricardo Neud
</a>',
'fields' => [
'ticketspam_company_name' => [
'FriendlyName' => 'Company Name',
'Type' => 'text',
'Size' => '15',
'Description' => 'Your company name for emails',
'Placeholder' => 'e.g. Your Company',
],
'ticketspam_no_reply_email' => [
'FriendlyName' => 'Email',
'Type' => 'text',
'Size' => '20',
'Description' => 'The email to send notifications for ticket auto-close (e.g. no-reply@example.com)',
'Placeholder' => 'e.g. no-reply@example.com',
],
'ticketspam_max_tickets' => [
'FriendlyName' => 'Maximum Number of Tickets',
'Type' => 'text',
'Size' => '5',
'Description' => 'Maximum number of tickets a user can submit within a certain time frame (e.g. 5)',
'Placeholder' => 'e.g. 5',
],
'ticketspam_time_limit' => [
'FriendlyName' => 'Time Limit (seconds)',
'Type' => 'text',
'Size' => '5',
'Description' => 'The time limit in seconds during which the tickets are counted (e.g. 300 for 5 minutes)',
'Placeholder' => 'e.g. 300',
],
],
];
}
function ticketspamcheck_activate() {
try {
Capsule::schema()->create('tblticketspamcheckdashboardsettings', function ($table) {
$table->increments('id');
$table->string('language', 10)->default('en');
$table->timestamps();
});
Capsule::schema()->create('tblticketspamcheckspamreports', function ($table) {
$table->increments('id');
$table->integer('client_id')->unsigned();
$table->string('client_name');
$table->string('client_email');
$table->integer('ticket_id')->unsigned();
$table->string('reason');
$table->timestamps();
});
return ['status' => 'success', 'description' => 'Ticket Spam Check add-on has been activated.'];
} catch (\Exception $e) {
return ['status' => 'error', 'description' => 'Error creating tables: ' . $e->getMessage()];
}
}
function ticketspamcheck_deactivate() {
try {
Capsule::schema()->dropIfExists('tblticketspamcheckdashboardsettings');
Capsule::schema()->dropIfExists('tblticketspamcheckspamreports');
return ['status' => 'success', 'description' => 'Ticket Spam Check add-on has been deactivated.'];
} catch (\Exception $e) {
return ['status' => 'error', 'description' => 'Error dropping tables: ' . $e->getMessage()];
}
}
function ticketspamcheck_output($vars) {
echo '<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; font-family: Arial, sans-serif;">';
echo '<h2 style="font-size: 24px; margin-bottom: 10px;">Welcome to the Ticket Spam Checker</h2>';
echo '<p style="font-size: 14px; margin-bottom: 20px;">Click the button below to access the dashboard.</p>';
echo '<form method="post" action="/modules/addons/ticketspamcheck/dashboard/home.php">';
echo '<button type="submit" style="padding: 8px 16px; font-size: 16px; cursor: pointer; background-color: #007BFF; color: white; border: none; border-radius: 4px;">Open Dashboard</button>';
echo '</form>';
echo '</div>';
}
© 2023 Quttera Ltd. All rights reserved.