mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 14:04:34 +00:00
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
if (PHP_SAPI !== 'cli')
|
|
{
|
|
http_response_code(404);
|
|
exit;
|
|
}
|
|
|
|
$query = '';
|
|
foreach ($argv as $arg)
|
|
{
|
|
if (strpos($arg, '--query=') === 0)
|
|
{
|
|
$query = substr($arg, strlen('--query='));
|
|
}
|
|
}
|
|
if ($query === '')
|
|
{
|
|
fwrite(STDERR, "Parameter --query fehlt.\n");
|
|
exit(2);
|
|
}
|
|
|
|
$piwigo_root = realpath(dirname(__DIR__, 4));
|
|
$plugin_root = realpath(dirname(__DIR__, 2));
|
|
if ($piwigo_root === false || $plugin_root === false || !is_file($plugin_root.'/watermark.php'))
|
|
{
|
|
fwrite(STDERR, "Piwigo-Root oder Bratonien-Wasserzeichenmodul wurde nicht gefunden.\n");
|
|
exit(3);
|
|
}
|
|
|
|
$plugin_id = basename($plugin_root);
|
|
parse_str($query, $_GET);
|
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
|
$_SERVER['SERVER_ADDR'] = '127.0.0.1';
|
|
$_SERVER['SERVER_NAME'] = 'localhost';
|
|
$_SERVER['HTTP_HOST'] = 'localhost';
|
|
$_SERVER['SERVER_PORT'] = '80';
|
|
$_SERVER['REQUEST_METHOD'] = 'GET';
|
|
$_SERVER['REQUEST_URI'] = '/plugins/'.$plugin_id.'/watermark.php?'.$query;
|
|
$_SERVER['SCRIPT_NAME'] = '/plugins/'.$plugin_id.'/watermark.php';
|
|
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
|
|
$_SERVER['QUERY_STRING'] = $query;
|
|
$_SERVER['HTTP_USER_AGENT'] = 'Bratonien-Presentation-Refresh/0.9.7.1.41';
|
|
$_SERVER['HTTPS'] = 'off';
|
|
|
|
chdir($piwigo_root);
|
|
include $plugin_root.'/watermark.php';
|