run:R W Run
7.55 KB
2026-04-08 19:24:59
R W Run
1.56 KB
2026-04-08 19:24:57
R W Run
1.34 KB
2026-04-08 19:24:56
R W Run
787 By
2026-04-08 19:24:58
R W Run
29.66 KB
2026-04-08 19:24:57
R W Run
6.35 KB
2026-04-08 19:24:57
R W Run
851 By
2026-04-08 19:24:58
R W Run
4.56 KB
2026-04-08 19:24:57
R W Run
11.08 KB
2026-04-08 19:24:56
R W Run
2.83 KB
2026-04-08 19:24:59
R W Run
40 By
2026-04-08 19:24:56
R W Run
39.18 KB
2026-04-08 19:24:57
R W Run
69.96 KB
2026-04-08 19:24:57
R W Run
310 By
2026-04-08 19:24:57
R W Run
12.03 KB
2026-04-08 19:24:57
R W Run
error_log
📄cancel_requests.php
1<?php
2// Include necessary files
3require_once __DIR__ . '/../configuration.php'; // Adjust the path as necessary
4require_once __DIR__ . '/../init.php'; // Make sure to include necessary WHMCS init for database access
5
6use WHMCS\Database\Capsule;
7
8// Define the current date and time
9$currentDate = date('Y-m-d H:i:s');
10
11// Query the tblcancelrequests table for requests where the cancel date <= current date
12$cancelRequests = Capsule::table('tblcancelrequests')
13 ->where('date', '<=', $currentDate) // Use the 'date' field for cancellation requests
14 ->get();
15
16// Loop through all cancellation requests and update the corresponding hosting account
17foreach ($cancelRequests as $request) {
18 // Check if the user has an active hosting plan in tblhosting (using relid which corresponds to id)
19 $hosting = Capsule::table('tblhosting')
20 ->where('id', $request->relid) // Use relid to identify the hosting account (corresponds to id in tblhosting)
21 ->where('domainstatus', 'Active') // Ensure the hosting account is active using domainstatus
22 ->first();
23
24 // If a valid hosting account is found, cancel the subscription
25 if ($hosting) {
26 Capsule::table('tblhosting')
27 ->where('id', $hosting->id)
28 ->update([
29 'domainstatus' => 'Cancelled', // Update the domainstatus to cancelled
30 // WHMCS will automatically handle the cancel_date field when status changes
31 ]);
32
33 echo "Cancelled subscription for user: {$request->relid}, Cancel Request ID: {$request->id}\n";
34 }
35}
36?>