38 lines
1.5 KiB
PHP
38 lines
1.5 KiB
PHP
<?php
|
|
// Only copied into a temporary test document root. Never used by the application.
|
|
session_start();
|
|
$groups = ['Allgemein' => !isset($_GET['deny'])];
|
|
$user = ['mail' => 'member@example.test', 'first_name' => 'Test', 'last_name' => 'Person'];
|
|
class TestStatement extends PDOStatement
|
|
{
|
|
public function __construct(private string $sql) {}
|
|
public function execute(?array $params = null): bool
|
|
{
|
|
if (!str_starts_with($this->sql, 'SELECT')) {
|
|
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/writes.jsonl', json_encode([$this->sql, $params]) . "\n", FILE_APPEND);
|
|
}
|
|
return true;
|
|
}
|
|
public function fetchAll(int $mode = PDO::FETCH_DEFAULT, mixed ...$args): array
|
|
{
|
|
return str_contains($this->sql, 'FROM gottesdienst')
|
|
? [['id' => 1, 'title' => 'Joh 3,16', 'subtitle' => '<script>unsafe()</script>', 'date' => '2030-12-31']]
|
|
: [['id' => 2, 'title' => 'Gemeindefest', 'subtitle' => '', 'location' => 'Gemeindesaal',
|
|
'time' => '11:30:00', 'date' => '2030-12-31', 'end_date' => null]];
|
|
}
|
|
}
|
|
class TestPDO extends PDO
|
|
{
|
|
public function __construct() {}
|
|
public function prepare(string $query, array $options = []): PDOStatement|false
|
|
{
|
|
return new TestStatement($query);
|
|
}
|
|
public function query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs): PDOStatement|false
|
|
{
|
|
return new TestStatement($query);
|
|
}
|
|
public function exec(string $statement): int|false { return 0; }
|
|
}
|
|
$pdo = new TestPDO();
|