feat: Add custom user agent for API requests

This commit is contained in:
overflowerror 2024-07-29 22:49:41 +02:00
parent 6f46f9851e
commit 1f00915f81
4 changed files with 13 additions and 4 deletions

View file

@ -4,4 +4,7 @@ const POSTGRES_HOST = "%DBHOST%";
const POSTGRES_PORT = 5432;
const POSTGRES_DBNAME = "%DBNAME%";
const POSTGRES_USER = "%DBUSER%";
const POSTGRES_PASSWORD = "%DBPASSWORD%";
const POSTGRES_PASSWORD = "%DBPASSWORD%";
const CONTACT_EMAIL = "%EMAIL%";

View file

@ -1,5 +1,7 @@
<?php
require_once __DIR__ . '/lib/migrate.php';
require_once __DIR__ . "/version.php";
require_once __DIR__ . "/lib/migrate.php";
migrate();

View file

@ -1,6 +1,6 @@
<?php
require_once __DIR__ . "/../credentials.php";
require_once __DIR__ . "/../config.php";
$dsn = "pgsql:host=" . POSTGRES_HOST . ";dbname=" . POSTGRES_DBNAME . ";port=" . POSTGRES_PORT;

View file

@ -1,9 +1,13 @@
<?php
require_once __DIR__ . "/../config.php";
const USER_AGENT = "MobMash Updater/" . VERSION . " (+https://github.com/overflowerror/mobmash.click; contact: " . CONTACT_EMAIL . ")";
function get(string $url): string {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36');
curl_setopt($curl, CURLOPT_USERAGENT, USER_AGENT);
$response = curl_exec($curl);
curl_close($curl);
return $response;