8 Commits

Author SHA1 Message Date
086e7c7a77 full path 2025-06-10 12:00:35 +02:00
181bed4449 config corrections 2025-06-10 11:57:16 +02:00
6e0795bbdf url 2025-06-10 11:55:13 +02:00
5df5a0ad7a added logging
All checks were successful
Build Container / docker (push) Successful in 1m23s
2025-06-10 11:50:24 +02:00
63b49dd282 url showing 2025-06-10 11:25:27 +02:00
5e8f4e33e3 ups 2025-06-10 11:23:45 +02:00
a140a35448 symlink 2025-06-10 11:21:11 +02:00
a0765efc3c ok 2025-06-10 11:16:25 +02:00
48 changed files with 97 additions and 40 deletions

0
.devcontainer/Caddyfile Normal file → Executable file
View File

0
.devcontainer/Dockerfile Normal file → Executable file
View File

0
.devcontainer/devcontainer.json Normal file → Executable file
View File

0
.devcontainer/start.sh Normal file → Executable file
View File

0
.vscode/launch.json vendored Normal file → Executable file
View File

0
LICENSE.md Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
cache/.gitignore vendored Normal file → Executable file
View File

0
docker-compose-dev.yml Normal file → Executable file
View File

2
docker-compose.yml Normal file → Executable file
View File

@ -1,7 +1,7 @@
version: '3.3'
services:
http2pic:
image: ghcr.io/hascheksolutions/http2pic:2
image: gitea.haschek.at/haschek-solutions/http2pic:2
restart: unless-stopped
environment:

View File

@ -12,6 +12,9 @@ RUN echo "error_log = /srv/logs/php_errors.log" >> /etc/php84/php.ini
RUN apk add --no-cache php84-ctype php84-dom php84-fileinfo php84-gd php84-iconv php84-simplexml php84-xml php84-xmlreader php84-xmlwriter php84-zip php84-phar php84-openssl
RUN curl -sS https://getcomposer.org/installer | /usr/bin/php84 -- --install-dir=/usr/bin --filename=composer
# add symlink for php
RUN ln -s /usr/bin/php84 /usr/bin/php
ADD docker/start.sh /start.sh
RUN chmod +x /start.sh

21
docker/dokploy-compose.yml Executable file
View File

@ -0,0 +1,21 @@
services:
http2pic:
build:
context: ../
dockerfile: docker/Dockerfile
restart: unless-stopped
ports:
- 80
environment:
- URL=https://http2pic.haschek.at
networks:
- dokploy-network
labels:
- "traefik.enable=true"
- "traefik.http.routers.http2pic.rule=Host(`http2pic.haschek.at`)"
- "traefik.http.routers.http2pic.entrypoints=websecure"
- "traefik.http.routers.http2pic.tls.certResolver=letsencrypt"
- "traefik.http.services.http2pic.loadbalancer.server.port=80"
networks:
dokploy-network:
external: true

View File

@ -3,7 +3,7 @@ echo ' [+] Starting php'
php-fpm84
cd /srv/src
composer install
composer install --no-dev --optimize-autoloader
echo ' [+] Starting Chrome'
chromedriver --port=4444 &
@ -20,6 +20,6 @@ _buildConfig() {
echo ""
}
_buildConfig > src/inc/config.inc.php
_buildConfig > /srv/src/config.inc.php
caddy run --config /etc/caddy/Caddyfile

1
src/.gitignore vendored Normal file → Executable file
View File

@ -1 +1,2 @@
vendor/
config.inc.php

0
src/composer.json Normal file → Executable file
View File

0
src/composer.lock generated Normal file → Executable file
View File

0
src/config.inc.php → src/config.inc.php.php Normal file → Executable file
View File

3
src/example.config.inc.php Executable file
View File

@ -0,0 +1,3 @@
<?php
define('URL','http://localhost:8080');

19
src/helpers.php Normal file → Executable file
View File

@ -14,3 +14,22 @@ function renderTemplate($templatename,$variables=[],$basepath=ROOT.'/src')
return $rendered;
}
function addToLog($data)
{
$fp = fopen(ROOT.DS.'logs'.DS.'app.log','a');
fwrite($fp,date("d.m.y H:i")."\t".$data."\n");
fclose($fp);
}
function getUserIP()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}

0
src/http2pic.class.php Normal file → Executable file
View File

2
src/templates/index.html.php Normal file → Executable file
View File

@ -71,7 +71,7 @@
<!-- Main Content -->
<div class="container">
<h2>How the API works</h2>
<div class="well"><h2 ><?=URL?>/api/url=<span style="color:#1e90ff">[WEBSITE_URL]</span>&amp;<span style="color:#C73C49">[OPTIONS]</span></h2></div><hr/><br/>
<div class="well"><h2 ><?=URL?>/api/?url=<span style="color:#1e90ff">[WEBSITE_URL]</span>&amp;<span style="color:#C73C49">[OPTIONS]</span></h2></div><hr/><br/>
<div >
<div>
<section>

0
web/css/bootstrap.css vendored Normal file → Executable file
View File

0
web/css/bootstrap.min.css vendored Normal file → Executable file
View File

0
web/css/clean-blog.css Normal file → Executable file
View File

0
web/css/clean-blog.min.css vendored Normal file → Executable file
View File

0
web/css/http2pic.css Normal file → Executable file
View File

0
web/fonts/glyphicons-halflings-regular.eot Normal file → Executable file
View File

0
web/fonts/glyphicons-halflings-regular.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

0
web/fonts/glyphicons-halflings-regular.ttf Normal file → Executable file
View File

0
web/fonts/glyphicons-halflings-regular.woff Normal file → Executable file
View File

0
web/fonts/glyphicons-halflings-regular.woff2 Normal file → Executable file
View File

0
web/img/domainfailed.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

0
web/img/failed.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

0
web/img/home-bg.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 169 KiB

0
web/img/hs_logo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

0
web/img/loading.gif Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 200 KiB

0
web/img/pagefailed.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

34
web/index.php Normal file → Executable file
View File

@ -1,4 +1,5 @@
<?php
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
@ -17,19 +18,24 @@ if(php_sapi_name()=='cli-server' && file_exists(ROOT.DS.'web'.DS.implode('/',$ur
return false;
switch($url[0])
{
switch ($url[0]) {
case 'api':
$target = substr($_SERVER['REQUEST_URI'], 5);
if (!$target || !filter_var($target, FILTER_VALIDATE_URL))
$target = $_REQUEST['url'];
if(!filter_var($target, FILTER_VALIDATE_URL))
{
if (!filter_var($target, FILTER_VALIDATE_URL)) {
header('HTTP/1.0 400 Bad Request');
echo 'Invalid URL';
exit;
}
$viewport = $_REQUEST['viewport'];
$ip = getUserIP();
$viewport = $_REQUEST['viewport'] ?? '1024x768';
if (!preg_match('/^\d+x\d+$/', $viewport)) {
header('HTTP/1.0 400 Bad Request');
echo 'Invalid viewport format. Use WIDTHxHEIGHT (e.g., 1024x768)';
exit;
}
$js = $_REQUEST['js'] == 'false' ? false : true;
$serverUrl = 'http://localhost:4444';
@ -43,25 +49,29 @@ switch($url[0])
if (!$js)
$capabilities->setCapability('javascriptEnabled', false);
try {
$driver = RemoteWebDriver::create($serverUrl, $capabilities);
$driver->get($target);
//hide scroll bars
$driver->executeScript('document.body.style.overflow = "hidden";');
//set screenshot size to 1920x1080
//$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension(1024, 768));
//if $viewport is set, set window size
if($viewport)
{
if ($viewport) {
$viewport = explode('x', $viewport);
$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension($viewport[0], $viewport[1]));
}
else
{
} else {
$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension(1024, 768));
}
addToLog("$ip\tRequested $target with viewport " . implode('x', $viewport) . " and js " . ($js ? 'enabled' : 'disabled'));
} catch (Exception $e) {
header('HTTP/1.0 500 Internal Server Error');
addToLog("$ip\tRequested $target but resulted in error:\t" . $e->getMessage());
echo 'Error: ' . $e->getMessage();
exit;
}
// take screenshot and save to file
//header for png

0
web/js/bootstrap.js vendored Normal file → Executable file
View File

0
web/js/bootstrap.min.js vendored Normal file → Executable file
View File

0
web/js/clean-blog.js Normal file → Executable file
View File

0
web/js/clean-blog.min.js vendored Normal file → Executable file
View File

0
web/js/http2pic.js Normal file → Executable file
View File

0
web/js/jquery.js vendored Normal file → Executable file
View File

0
web/js/jquery.min.js vendored Normal file → Executable file
View File

0
web/less/clean-blog.less Normal file → Executable file
View File

0
web/less/mixins.less Normal file → Executable file
View File

0
web/less/variables.less Normal file → Executable file
View File