· 7 months ago · Mar 14, 2025, 05:15 AM
1add_shortcode( 'my-like-tools', 'my_like_tools' );
2
3
4function my_like_tools() {
5
6 // Database connection details
7 $host = 'localhost';
8 $dbname = 'jnews_support_db';
9 $username = 'root';
10 $password = 'root';
11
12 // Keep existing API configuration
13 $API_KEYS = array(
14 'ind' => '153987',
15 'bd' => '153987',
16 'ru' => '153987',
17 'eu' => '153987',
18 'id' => '153987',
19 'mea' => '153987',
20 'pk' => '153987',
21 'sg' => '153987',
22 'th' => '153987',
23 'tw' => '153987',
24 'vn' => '153987',
25 'na' => '153987',
26 'br' => '153987',
27 'sac' => '153987',
28 );
29
30 define( 'API_BASE_URL', 'https://freefireinfolikesender.onrender.com/' );
31 define( 'CLOUDFLARE_SECRET_KEY', '0x4AAAAAABAe_HDnLtGYzIW6tT-OBHlO4l4' );
32
33 // Add profile API constant
34 define( 'PROFILE_API_URL', 'https://freefireinfoxsmartclownprofileinfo.vercel.app/api' );
35
36 // Whitelist IP addresses
37 $WHITELIST_IPS = array(
38 '2401:4900:7073:fbb9:82f6:33b3:e1a0:1110',
39 '110.224.96.153',
40 );
41
42 $error = null;
43 $result = null;
44 $uid = '';
45 $region = '';
46
47 // Define absolute paths for log files
48 $logDir = __DIR__;
49 $ipLogFile = $logDir . '/ip_log.json';
50 $countingLogFile = $logDir . '/counting_log.json';
51 $historyLogFile = $logDir . '/history_log.json';
52
53 // Database connection
54 try {
55 $pdo = new PDO( "mysql:host=$host;dbname=$dbname", $username, $password );
56 $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
57 } catch ( PDOException $e ) {
58 die( 'Database connection failed: ' . $e->getMessage() );
59 }
60
61 // Handle Form Submission
62 if ( $_SERVER['REQUEST_METHOD'] === 'POST' ) {
63 // Check if it's a redirect request from success/error popup
64 if ( isset( $_POST['redirect'] ) ) {
65 // Just redirect to the main page without showing error
66 wp_redirect( get_permalink() );
67 exit;
68 }
69
70 $token = $_POST['cf-turnstile-response'] ?? '';
71 if ( empty( $token ) || ! verifyTurnstileToken( $token ) ) {
72 $error = 'Human verification failed. Please try again.';
73 } else {
74 $uid = htmlspecialchars( $_POST['uid'] ?? '' );
75 $userIP = getUserIP();
76
77 if ( empty( $uid ) ) {
78 $error = 'UID is required.';
79 } else {
80 $limitCheck = checkIPAndUIDLimit( $userIP, $uid );
81 if ( ! $limitCheck['status'] ) {
82 $error = $limitCheck['message'];
83 } else {
84 // Try to determine region
85 $detectedRegion = tryRegions( $uid );
86
87 if ( $detectedRegion === false ) {
88 $error = 'Could not determine the correct region for this UID.';
89 } else {
90 $apiKey = $API_KEYS[ $detectedRegion ];
91 $apiUrl = sprintf( '%s/%s/%s/%s', API_BASE_URL, $uid, $detectedRegion, $apiKey );
92
93 $response = @file_get_contents( $apiUrl );
94 if ( $response === false ) {
95 $error = 'Failed to connect to the API.';
96 } else {
97 $result = json_decode( $response, true );
98
99 // FIXED: Only increment region counter when likes are actually sent
100 if ( isset( $result['status'] ) ) {
101 incrementRegionCounter( $detectedRegion, $result['status'] );
102 }
103
104 if ( isset( $result['status'] ) && $result['status'] === 1 ) {
105 // Log successful request (likes were actually sent)
106 logSuccessfulRequest( $userIP, $uid );
107 } else {
108 // Log failed request (valid UID but likes were not sent)
109 logFailedRequest( $userIP, $uid );
110 }
111
112 logApiResponse( $result );
113 $_SESSION['last_submission'] = $result;
114 wp_redirect( add_query_arg( 'success', '1', get_permalink() ) );
115 exit;
116 }
117 }
118 }
119 }
120 }
121 }
122
123 if ( isset( $_SESSION['last_submission'] ) && isset( $_GET['success'] ) ) {
124 $result = $_SESSION['last_submission'];
125 unset( $_SESSION['last_submission'] );
126 }
127
128 ?>
129
130 <div class="my-like-tools">
131 <h1 style="font-size: 20px;">Claim 100 Likes Via UID For Free</h1>
132 <img src="https://freefireinfo.in/wp-content/uploads/2024/12/Claim-100-Likes-Via-UID-For-Free-1024x576.jpg" alt="Claim 100 Likes Via UID For Free" style="width: 100%; height: auto; margin-bottom: 15px;">
133
134 <div class="like-sender-app">
135 <span style="font-size: 18px;">In Game, likes show how cool and skilled a player is. If someone has lots of likes, it means others think they play really well. It also makes their profile look more popular and respected. Getting more likes can help you stand out and feel proud of your game skills!</span>
136
137 <span style="font-size: 18px;">Before, players could get likes in Game through craftland maps. But now, all those official ways are closed.</span>
138
139 <span style="font-size: 18px;">That's why I made this tool to give free likes, just like people wanted. You don't need any hack or app—just the player's UID!</span>
140
141 <h2><span style="font-size: 20px;">Steps to Get Free Likes:</span></h2>
142 <ol>
143 <li><span style="font-size: 18px;">Type your Game UID in the box.</span></li>
144 <li><span style="font-size: 18px;">Click the "Claim" button.</span></li>
145 <li><span style="font-size: 18px;">The system will send likes to your UID.</span></li>
146 <li><span style="font-size: 18px;">Check the status under the status field below the input box.</span></li>
147 </ol>
148 <span style="font-size: 18px;">There are a few limitations to claim likes. It works on a first-come, first-served basis, so only the early users at the start of the day can get likes.</span>
149 <h2><span style="font-size: 20px;">Important Notes:</span></h2>
150 <span style="font-size: 18px;">A UID can receive only 100 likes in 24 hours. After claiming likes from this tool, the player cannot get any more likes from the game or this tool until the 24-hour limit resets. Even if teammates or profile visitors try to send likes in the game, those likes will not be added to the account. This rule is set by game officials.</span>
151
152 <span style="font-size: 18px;">This tool is a simple and safe way to get free likes for your Game account. It works quickly and follows all the game rules without any risk of bans. Start using it today to make your profile stand out and look more popular!</span>
153
154 <form method="POST" id="likeForm">
155 <div class="form-group">
156 <label for="uid">Enter UID:</label>
157 <input type="text" name="uid" id="uid" value="<?php echo htmlspecialchars( $uid ); ?>" required
158 placeholder="Enter your UID">
159 </div>
160
161 <!-- Cloudflare Turnstile widget -->
162 <div class="cf-turnstile" data-sitekey="0x4AAAAAABAe_Da-31Q7nqIm"></div>
163
164 <button type="submit">Claim Free Likes</button>
165 </form>
166
167 <div id="loading" class="loading">
168 Trying to send likes...
169 </div>
170
171 <?php if ( isset( $_GET['success'] ) && $_GET['success'] == 1 && $result ) : ?>
172 <div class="popup-overlay">
173 <div class="popup-box">
174 <h3 class="<?php echo ( isset( $result['status'] ) && $result['status'] === 1 ) ? 'success' : 'error'; ?>">
175 <?php echo ( isset( $result['status'] ) && $result['status'] === 1 ) ? 'Success!' : 'Notification'; ?>
176 </h3>
177 <p>
178 <?php
179 if ( isset( $result['status'] ) && $result['status'] === 1 ) {
180 echo '<p>Booyah! ' . htmlspecialchars( $result['PlayerNickname'] ) . ', You have successfully claimed ' . htmlspecialchars( $result['LikesGivenByAPI'] ) . ' likes!</p>' .
181 "<p>Player's Nickname: " . htmlspecialchars( $result['PlayerNickname'] ) . '</p>' .
182 "<p>Player's Uid: " . htmlspecialchars( $result['UID'] ) . '</p>' .
183 '<p>Likes before Sent: ' . htmlspecialchars( $result['LikesbeforeCommand'] ) . '</p>' .
184 '<p>Likes after Sent: ' . htmlspecialchars( $result['LikesafterCommand'] ) . '</p>' .
185 '<p>Likes Given: ' . htmlspecialchars( $result['LikesGivenByAPI'] ) . '</p>' .
186 '<p>Please come back after 24 hours to claim your free like again.</p>';
187 } else {
188 echo '<p>Oops! ' . htmlspecialchars( $result['PlayerNickname'] ) . ', ' .
189 ( $result['status'] === 2 ?
190 "you've received 100 likes in last 24 hours. Please try again later." :
191 "Dear user, the system can't send likes because all available likes have already been claimed by other users. Since this service operates on a first-come, first-served basis, please come back tomorrow to claim your free likes." ) .
192 '</p>';
193 }
194 ?>
195 </p>
196 <a href="<?php echo esc_url( get_permalink() ); ?>">
197 <button class="popup-button <?php echo ( isset( $result['status'] ) && $result['status'] === 1 ) ? 'success' : 'error'; ?>">OK</button>
198 </a>
199 </div>
200 </div>
201 <?php elseif ( $error ) : ?>
202 <div class="popup-overlay">
203 <div class="popup-box">
204 <h3 class="error">Notification</h3>
205 <p><?php echo $error; ?></p>
206 <a href="<?php echo esc_url( get_permalink() ); ?>">
207 <button class="popup-button error">OK</button>
208 </a>
209 </div>
210 </div>
211 <?php endif; ?>
212
213 <div class="navigation">
214 <a href="https://tools.freefireinfo.in/history.php">Check History →</a>
215 </div>
216 </div>
217
218 <span style="font-size: 18px;">This tool is a simple and safe way to get free likes for your Game account. It works quickly and follows all the game rules without any risk of bans. Start using it today to make your profile stand out and look more popular!</span>
219 </div>
220
221
222 <style>
223 /* Keep existing CSS exactly the same */
224 :root {
225 --primary-color: #3498db;
226 --secondary-color: #2c3e50;
227 --success-color: #2ecc71;
228 --error-color: #e74c3c;
229 --bg-color: #FFFFFF;
230 --border-radius: 8px;
231 }
232
233 .like-sender-app {
234 font-family: 'Poppins', sans-serif;
235 max-width: 100%;
236 margin: 0 auto;
237 padding: 20px;
238 background-color: var(--bg-color);
239 color: var(--secondary-color);
240 }
241
242 h1 {
243 text-align: center;
244 color: var(--secondary-color);
245 margin-bottom: 30px;
246 font-size: 2em;
247 text-transform: uppercase;
248 letter-spacing: 1px;
249 }
250
251 .form-group {
252 margin-bottom: 20px;
253 }
254
255 label {
256 display: block;
257 margin-bottom: 8px;
258 font-weight: 600;
259 color: var(--secondary-color);
260 }
261
262 input, select {
263 width: 100%;
264 padding: 12px;
265 border: 2px solid #ddd;
266 border-radius: var(--border-radius);
267 font-size: 16px;
268 transition: all 0.3s ease;
269 background-color: white;
270 box-sizing: border-box;
271 height: 45px;
272 }
273
274 input:focus, select:focus {
275 border-color: var(--primary-color);
276 outline: none;
277 box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
278 }
279
280 button {
281 width: 100%;
282 padding: 12px;
283 background-color: var(--primary-color);
284 color: white;
285 border: none;
286 border-radius: var(--border-radius);
287 font-size: 16px;
288 cursor: pointer;
289 transition: all 0.3s ease;
290 text-transform: uppercase;
291 letter-spacing: 1px;
292 font-weight: 600;
293 height: 45px;
294 }
295
296 button:hover {
297 background-color: #2980b9;
298 transform: translateY(-1px);
299 box-shadow: 0 4px 6px rgba(0,0,0,0.1);
300 }
301
302 button:active {
303 transform: translateY(0);
304 box-shadow: none;
305 }
306
307 .loading {
308 display: none;
309 text-align: center;
310 margin-top: 20px;
311 }
312
313 .loading.active {
314 display: block;
315 }
316
317 @keyframes slideIn {
318 from {
319 transform: translateY(-20px);
320 opacity: 0;
321 }
322 to {
323 transform: translateY(0);
324 opacity: 1;
325 }
326 }
327
328 select {
329 appearance: none;
330 background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
331 background-repeat: no-repeat;
332 background-position: right 1rem center;
333 background-size: 1em;
334 padding-right: 2.5rem;
335 }
336
337 .cf-turnstile {
338 margin: 20px 0;
339 display: flex;
340 justify-content: center;
341 }
342
343 /* Updated popup styles */
344 .popup-overlay {
345 position: fixed;
346 top: 0;
347 left: 0;
348 width: 100%;
349 height: 100%;
350 background-color: rgba(0, 0, 0, 0.5);
351 display: flex;
352 justify-content: center;
353 align-items: center;
354 z-index: 1000;
355 backdrop-filter: blur(8px);
356 -webkit-backdrop-filter: blur(8px);
357 }
358
359 .popup-box {
360 background: white;
361 padding: 25px;
362 border-radius: 10px;
363 width: 280px;
364 max-width: 85%;
365 box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
366 text-align: center;
367 animation: popIn 0.3s ease-out;
368 }
369
370 @keyframes popIn {
371 from {
372 transform: scale(0.8);
373 opacity: 0;
374 }
375 to {
376 transform: scale(1);
377 opacity: 1;
378 }
379 }
380
381 .popup-box h3 {
382 margin-top: 0;
383 }
384
385 .popup-box h3.success {
386 color: var(--success-color);
387 }
388
389 .popup-box h3.error {
390 color: var(--error-color);
391 }
392
393 .popup-box p {
394 margin-bottom: 20px;
395 line-height: 1.5;
396 }
397
398 .popup-button {
399 width: 120px;
400 margin: 0 auto;
401 }
402
403 .popup-button.success {
404 background-color: var(--success-color);
405 }
406
407 .popup-button.success:hover {
408 background-color: #27ae60;
409 }
410
411 .popup-button.error {
412 background-color: var(--error-color);
413 }
414
415 .popup-button.error:hover {
416 background-color: #c0392b;
417 }
418 .navigation {
419 margin-top: 20px;
420 display: flex;
421 justify-content: space-between;
422 align-items: center;
423 }
424
425 .navigation a {
426 text-decoration: none;
427 color: #3498db;
428 font-weight: 600;
429 }
430
431 .navigation a:hover {
432 text-decoration: underline;
433 }
434 </style>
435
436 <script>
437 document.getElementById('likeForm').addEventListener('submit', function() {
438 document.getElementById('loading').classList.add('active');
439 });
440
441 // Add the Cloudflare Turnstile script to the page
442 // This script loads the Cloudflare Turnstile widget
443 (function() {
444 // Add the script to the page
445 const script = document.createElement('script');
446 script.src = 'https://challenges.cloudflare.com/turnstile/v0/api.js';
447 script.async = true;
448 script.defer = true;
449 document.head.appendChild(script);
450 })();
451 </script>
452 <?php
453}
454
455
456// Add new function to verify region
457function verifyRegion( $uid, $region ) {
458 $apiUrl = PROFILE_API_URL . "?uid={$uid}®ion={$region}&key=1542045198";
459 $response = @file_get_contents( $apiUrl );
460
461 if ( $response === false ) {
462 return false;
463 }
464
465 $data = json_decode( $response, true );
466 return isset( $data['AccountInfo'] );
467}
468
469// Add new function to try regions
470function tryRegions( $uid ) {
471 // Define regions to try in order
472 $regionsToTry = array( 'sg', 'ind', 'na' );
473
474 foreach ( $regionsToTry as $region ) {
475 if ( verifyRegion( $uid, $region ) ) {
476 return $region;
477 }
478 }
479
480 return false;
481}
482
483// Keep all existing functions
484function verifyTurnstileToken( $token ) {
485 $data = array(
486 'secret' => CLOUDFLARE_SECRET_KEY,
487 'response' => $token,
488 'remoteip' => $_SERVER['REMOTE_ADDR'],
489 );
490
491 $ch = curl_init( 'https://challenges.cloudflare.com/turnstile/v0/siteverify' );
492 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
493 curl_setopt( $ch, CURLOPT_POST, true );
494 curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $data ) );
495
496 $response = curl_exec( $ch );
497 curl_close( $ch );
498
499 $result = json_decode( $response, true );
500 return isset( $result['success'] ) && $result['success'] === true;
501}
502
503function getUserIP() {
504 if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
505 return $_SERVER['HTTP_CLIENT_IP'];
506 } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
507 return $_SERVER['HTTP_X_FORWARDED_FOR'];
508 } else {
509 return $_SERVER['REMOTE_ADDR'];
510 }
511}
512
513function checkIPAndUIDLimit( $ip, $uid ) {
514 global $WHITELIST_IPS, $ipLogFile;
515
516 // Check if IP is in the whitelist
517 if ( in_array( $ip, $WHITELIST_IPS ) ) {
518 return array( 'status' => true ); // Whitelisted IPs have no limits
519 }
520
521 $currentTime = time();
522 date_default_timezone_set( 'Asia/Kolkata' );
523 $todayReset = strtotime( 'today 4:00' );
524 $nextReset = $todayReset;
525
526 if ( $currentTime > $todayReset ) {
527 $nextReset = strtotime( 'tomorrow 4:00' );
528 }
529
530 $ipLog = array();
531 if ( file_exists( $ipLogFile ) ) {
532 $ipLog = json_decode( file_get_contents( $ipLogFile ), true ) ?? array();
533
534 if ( $currentTime > $todayReset && isset( $ipLog['last_reset'] ) && $ipLog['last_reset'] < $todayReset ) {
535 $ipLog = array(
536 'last_reset' => $currentTime,
537 'ips' => array(),
538 'uids' => array(),
539 );
540 }
541 }
542
543 if ( ! isset( $ipLog['ips'][ $ip ] ) ) {
544 $ipLog['ips'][ $ip ] = array(
545 'count' => 0,
546 'timestamp' => array(),
547 'uids' => array(),
548 );
549 }
550 if ( ! isset( $ipLog['uids'] ) ) {
551 $ipLog['uids'] = array();
552 }
553
554 // FIXED: Check UID limit - if UID was used today, block regardless of likes sent status
555 if ( isset( $ipLog['uids'][ $uid ] ) ) {
556 $uidData = $ipLog['uids'][ $uid ];
557 if ( $uidData['timestamp'] >= $todayReset ) {
558 // Log this attempt
559 if ( ! isset( $ipLog['blocked_attempts'] ) ) {
560 $ipLog['blocked_attempts'] = array();
561 }
562 $ipLog['blocked_attempts'][] = array(
563 'uid' => $uid,
564 'ip' => $ip,
565 'original_ip' => $uidData['ip'],
566 'timestamp' => $currentTime,
567 );
568 file_put_contents( $ipLogFile, json_encode( $ipLog, JSON_PRETTY_PRINT ) );
569
570 // Block the attempt regardless of whether likes were sent or not
571 return array(
572 'status' => false,
573 'message' => 'This account (UID: ' . $uid . ') already attempted to receive likes today. Please wait 24 hours from the last claim.',
574 );
575 }
576 }
577
578 // Then check IP limit
579 if ( $ipLog['ips'][ $ip ]['count'] >= 2 ) {
580 return array(
581 'status' => false,
582 'message' => "System detected you've claimed free likes two times today. Come back tomorrow after 4 AM IST to claim free likes again.",
583 );
584 }
585
586 return array( 'status' => true );
587}
588
589function logSuccessfulRequest( $ip, $uid ) {
590 global $ipLogFile;
591 $currentTime = time();
592
593 $ipLog = array();
594 if ( file_exists( $ipLogFile ) ) {
595 $ipLog = json_decode( file_get_contents( $ipLogFile ), true ) ?? array();
596 }
597
598 if ( ! isset( $ipLog['ips'] ) ) {
599 $ipLog['ips'] = array();
600 }
601 if ( ! isset( $ipLog['uids'] ) ) {
602 $ipLog['uids'] = array();
603 }
604
605 if ( ! isset( $ipLog['ips'][ $ip ] ) ) {
606 $ipLog['ips'][ $ip ] = array(
607 'count' => 0,
608 'timestamp' => array(),
609 'uids' => array(),
610 );
611 }
612 ++$ipLog['ips'][ $ip ]['count'];
613 $ipLog['ips'][ $ip ]['timestamp'][] = $currentTime;
614 $ipLog['ips'][ $ip ]['uids'][] = $uid;
615
616 $ipLog['uids'][ $uid ] = array(
617 'timestamp' => $currentTime,
618 'ip' => $ip,
619 'likes_sent' => true,
620 );
621
622 file_put_contents( $ipLogFile, json_encode( $ipLog, JSON_PRETTY_PRINT ) );
623}
624
625// New function to log UID attempts where likes were not sent
626function logFailedRequest( $ip, $uid ) {
627 global $ipLogFile;
628 $currentTime = time();
629
630 $ipLog = array();
631 if ( file_exists( $ipLogFile ) ) {
632 $ipLog = json_decode( file_get_contents( $ipLogFile ), true ) ?? array();
633 }
634
635 if ( ! isset( $ipLog['uids'] ) ) {
636 $ipLog['uids'] = array();
637 }
638
639 // Log only the UID, not counting against IP limit
640 $ipLog['uids'][ $uid ] = array(
641 'timestamp' => $currentTime,
642 'ip' => $ip,
643 'likes_sent' => false,
644 );
645
646 file_put_contents( $ipLogFile, json_encode( $ipLog, JSON_PRETTY_PRINT ) );
647}
648
649function logApiResponse( $response ) {
650 global $historyLogFile;
651 date_default_timezone_set( 'Asia/Kolkata' );
652
653 $logEntry = array(
654 'timestamp' => date( 'Y-m-d h:i:s A (T)' ),
655 'nickname' => $response['PlayerNickname'],
656 'uid' => $response['UID'],
657 'likes_given' => $response['LikesGivenByAPI'],
658 'likes_before' => $response['LikesbeforeCommand'],
659 'likes_after' => $response['LikesafterCommand'],
660 );
661
662 $existingLog = array();
663 if ( file_exists( $historyLogFile ) ) {
664 $existingLog = json_decode( file_get_contents( $historyLogFile ), true ) ?? array();
665 }
666
667 $existingLog[] = $logEntry;
668 file_put_contents( $historyLogFile, json_encode( $existingLog, JSON_PRETTY_PRINT ) );
669}
670
671// FIXED: Completely rewritten function to independently check and reset counting_log.json at 4:00 AM IST
672function checkAndResetCountingLog() {
673 global $countingLogFile;
674
675 // Set timezone to IST
676 date_default_timezone_set( 'Asia/Kolkata' );
677
678 // Default structure
679 $defaultCounters = array(
680 'IND_TOKEN' => 0,
681 'USA_TOKEN' => 0,
682 'SEA_TOKEN' => 0,
683 'last_reset' => 0,
684 );
685
686 // Current time and today's reset time (4:00 AM)
687 $currentTime = time();
688 $todayReset = strtotime( 'today 4:00' );
689
690 // If file doesn't exist, create it with defaults
691 if ( ! file_exists( $countingLogFile ) ) {
692 file_put_contents( $countingLogFile, json_encode( $defaultCounters, JSON_PRETTY_PRINT ) );
693 return $defaultCounters;
694 }
695
696 // Read current counting log
697 $countingLog = json_decode( file_get_contents( $countingLogFile ), true ) ?? $defaultCounters;
698
699 // Ensure last_reset exists
700 if ( ! isset( $countingLog['last_reset'] ) ) {
701 $countingLog['last_reset'] = 0;
702 }
703
704 // Check if we need to reset (current time is after 4:00 AM and last reset was before 4:00 AM today)
705 if ( $currentTime > $todayReset && $countingLog['last_reset'] < $todayReset ) {
706 // Reset counters but keep the format
707 $countingLog = array(
708 'IND_TOKEN' => 0,
709 'USA_TOKEN' => 0,
710 'SEA_TOKEN' => 0,
711 'last_reset' => $currentTime,
712 );
713
714 // Save the reset log
715 file_put_contents( $countingLogFile, json_encode( $countingLog, JSON_PRETTY_PRINT ) );
716 }
717
718 return $countingLog;
719}
720
721// FIXED: Function to increment region counter with independent reset check
722function incrementRegionCounter( $region, $apiStatus ) {
723 global $countingLogFile;
724 // Only increment counter if status is 1 (successful likes sent)
725 if ( $apiStatus !== 1 ) {
726 return; // Don't increment if likes weren't sent
727 }
728
729 // First check and reset if needed
730 $countingLog = checkAndResetCountingLog();
731
732 // Map the region code to the token name
733 $tokenMap = array(
734 'ind' => 'IND_TOKEN',
735 'na' => 'USA_TOKEN',
736 'sg' => 'SEA_TOKEN',
737 );
738
739 // Increment the appropriate counter if the region is in our map
740 if ( isset( $tokenMap[ $region ] ) ) {
741 $tokenName = $tokenMap[ $region ];
742 ++$countingLog[ $tokenName ];
743
744 // Save the updated counters
745 file_put_contents( $countingLogFile, json_encode( $countingLog, JSON_PRETTY_PRINT ) );
746 }
747}