403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/innoceanapi.wondermakr.com/innocean-fifa-api/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/innoceanapi.wondermakr.com/innocean-fifa-api/app/functions.php
<?php

function is_https() {
	if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
		return true;
	} else {
		return false;
	}
}

function check_method() {
	return (trim(strtoupper($_SERVER['REQUEST_METHOD'])));
}

function respond(int $code, string $message, array $data = []): void {
	http_response_code($code);
	echo json_encode([
		'success' => $code < 400,
		'message' => $message,
		'data' => $data
	]);
	exit;
}

function validatePin($pin): string {
	if (!is_string($pin)) {
		respond(400, 'PIN must be a string.');
	}

	$pin = trim($pin);

	if (!preg_match('/^\d{5}$/', $pin)) {
		respond(400, 'PIN must be exactly 5 digits');
	}

	return $pin;
}

function validatePins($pins): array {
	if (!is_array($pins)) {
		respond(400, 'PINs must be an array.');
	}

	$count = count($pins);

	if ($count < 1 || $count > 4) {
		respond(400, 'You must provide between 1 and 4 PINs.');
	}

	$validatedPins = [];

	foreach ($pins as $pin) {
		$validatedPins[] = validatePin($pin);
	}

	return $validatedPins;
}

function isDuplicatePin($pin) {
	
	global $db;

	$query = $db->prepare("SELECT id FROM pin WHERE pin = :pin LIMIT 1");
	$query->execute([':pin' => $pin]);
	$result = $query->fetch(PDO::FETCH_ASSOC);
	
	if (!empty($result)) {
		return true;
	}
	
	return false;

}

function validateIntScore($value, string $fieldName): int {
	if (filter_var($value, FILTER_VALIDATE_INT) === false) {
		respond(400, $fieldName . ' must be an integer');
	}

	return (int) $value;
}

function validatePngFilename($file): string {
	if (!is_string($file)) {
		respond(400, 'Filename must be a string');
	}

	$file = trim($file);

	if ($file === '') {
		respond(400, 'Filename is required');
	}

	// Only allow a simple filename ending in .png
	if (!preg_match('/^[A-Za-z0-9._-]+\.png$/i', $file)) {
		respond(400, 'Filename must be a valid PNG file');
	}

	return $file;
}

function validateVideoFilename($file): string {
	if (!is_string($file)) {
		respond(400, 'Filename must be a string');
	}

	$file = trim($file);

	if ($file === '') {
		respond(400, 'Filename is required');
	}

	// Only allow a simple filename ending in .png
	if (!preg_match('/^[A-Za-z0-9._-]+\.webm$/i', $file)) {
		respond(400, 'Filename must be a valid webm file');
	}

	return $file;
}

function validateIds($ids): array {
	if (!is_array($ids)) {
		respond(400, 'IDs must be an array');
	}

	$count = count($ids);

	if ($count < 1 || $count > 4) {
		respond(400, 'You must provide between 1 and 4 IDs');
	}

	$validatedIds = [];

	foreach ($ids as $id) {
		if (filter_var($id, FILTER_VALIDATE_INT) === false) {
			respond(400, 'Each ID must be an integer');
		}

		$id = (int) $id;

		if ($id < 1) {
			respond(400, 'Each ID must be a positive integer');
		}

		$validatedIds[] = $id;
	}

	return $validatedIds;
}

function verifySignedRequest(string $rawBody) {
	
	global $cfg;
	
	$providedSignature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';

	if ($providedSignature === '') {
		respond(401, 'Missing signature header.');
	}	
	
	$expectedSignature = hash_hmac('sha256', $rawBody, $cfg['apiSecret']);

	if (!hash_equals($expectedSignature, $providedSignature)) {
		respond(401, 'Invalid signature.');
	}
	
}

?>

Youez - 2016 - github.com/yon3zu
LinuXploit