Compare commits
5 Commits
543e44abc8
...
v2.0.7
Author | SHA1 | Date | |
---|---|---|---|
5df5a0ad7a | |||
63b49dd282 | |||
5e8f4e33e3 | |||
a140a35448 | |||
a0765efc3c |
0
.devcontainer/Caddyfile
Normal file → Executable file
0
.devcontainer/Dockerfile
Normal file → Executable file
0
.devcontainer/devcontainer.json
Normal file → Executable file
0
.devcontainer/start.sh
Normal file → Executable file
0
.vscode/launch.json
vendored
Normal file → Executable file
0
LICENSE.md
Normal file → Executable file
0
cache/.gitignore
vendored
Normal file → Executable file
0
docker-compose-dev.yml
Normal file → Executable file
2
docker-compose.yml
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
version: '3.3'
|
version: '3.3'
|
||||||
services:
|
services:
|
||||||
http2pic:
|
http2pic:
|
||||||
image: ghcr.io/hascheksolutions/http2pic:2
|
image: gitea.haschek.at/haschek-solutions/http2pic:2
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
@ -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 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
|
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
|
ADD docker/start.sh /start.sh
|
||||||
RUN chmod +x /start.sh
|
RUN chmod +x /start.sh
|
||||||
|
|
||||||
|
21
docker/dokploy-compose.yml
Executable 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
|
@ -3,7 +3,7 @@ echo ' [+] Starting php'
|
|||||||
php-fpm84
|
php-fpm84
|
||||||
|
|
||||||
cd /srv/src
|
cd /srv/src
|
||||||
composer install
|
composer install --no-dev --optimize-autoloader
|
||||||
|
|
||||||
echo ' [+] Starting Chrome'
|
echo ' [+] Starting Chrome'
|
||||||
chromedriver --port=4444 &
|
chromedriver --port=4444 &
|
||||||
|
0
src/.gitignore
vendored
Normal file → Executable file
0
src/composer.json
Normal file → Executable file
0
src/composer.lock
generated
Normal file → Executable file
0
src/config.inc.php
Normal file → Executable file
19
src/helpers.php
Normal file → Executable file
@ -14,3 +14,22 @@ function renderTemplate($templatename,$variables=[],$basepath=ROOT.'/src')
|
|||||||
|
|
||||||
return $rendered;
|
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
2
src/templates/index.html.php
Normal file → Executable file
@ -71,7 +71,7 @@
|
|||||||
<!-- Main Content -->
|
<!-- Main Content -->
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>How the API works</h2>
|
<h2>How the API works</h2>
|
||||||
<div class="well"><h2 ><?=URL?>/api/url=<span style="color:#1e90ff">[WEBSITE_URL]</span>&<span style="color:#C73C49">[OPTIONS]</span></h2></div><hr/><br/>
|
<div class="well"><h2 ><?=URL?>/api/?url=<span style="color:#1e90ff">[WEBSITE_URL]</span>&<span style="color:#C73C49">[OPTIONS]</span></h2></div><hr/><br/>
|
||||||
<div >
|
<div >
|
||||||
<div>
|
<div>
|
||||||
<section>
|
<section>
|
||||||
|
0
web/css/bootstrap.css
vendored
Normal file → Executable file
0
web/css/bootstrap.min.css
vendored
Normal file → Executable file
0
web/css/clean-blog.css
Normal file → Executable file
0
web/css/clean-blog.min.css
vendored
Normal file → Executable file
0
web/css/http2pic.css
Normal file → Executable file
0
web/fonts/glyphicons-halflings-regular.eot
Normal file → Executable file
0
web/fonts/glyphicons-halflings-regular.svg
Normal file → Executable file
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
0
web/fonts/glyphicons-halflings-regular.ttf
Normal file → Executable file
0
web/fonts/glyphicons-halflings-regular.woff
Normal file → Executable file
0
web/fonts/glyphicons-halflings-regular.woff2
Normal file → Executable file
0
web/img/domainfailed.jpg
Normal file → Executable file
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
0
web/img/failed.jpg
Normal file → Executable file
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
0
web/img/home-bg.jpg
Normal file → Executable file
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 169 KiB |
0
web/img/hs_logo.png
Normal file → Executable file
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
0
web/img/loading.gif
Normal file → Executable file
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 200 KiB |
0
web/img/pagefailed.jpg
Normal file → Executable file
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
69
web/index.php
Normal file → Executable file
@ -1,36 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||||
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
||||||
|
|
||||||
define('DS', DIRECTORY_SEPARATOR);
|
define('DS', DIRECTORY_SEPARATOR);
|
||||||
define('ROOT', dirname(__FILE__).DS.'..');
|
define('ROOT', dirname(__FILE__) . DS . '..');
|
||||||
|
|
||||||
require_once(ROOT.DS.'src'.DS.'config.inc.php');
|
require_once(ROOT . DS . 'src' . DS . 'config.inc.php');
|
||||||
require_once(ROOT.DS.'src'.DS.'helpers.php');
|
require_once(ROOT . DS . 'src' . DS . 'helpers.php');
|
||||||
require_once(ROOT.DS.'src'.DS.'http2pic.class.php');
|
require_once(ROOT . DS . 'src' . DS . 'http2pic.class.php');
|
||||||
require_once(ROOT.DS.'src'.DS.'vendor'.DS.'autoload.php');
|
require_once(ROOT . DS . 'src' . DS . 'vendor' . DS . 'autoload.php');
|
||||||
|
|
||||||
$url = array_filter(explode('/',ltrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),'/')));
|
$url = array_filter(explode('/', ltrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/')));
|
||||||
|
|
||||||
//check for integrated server
|
//check for integrated server
|
||||||
if(php_sapi_name()=='cli-server' && file_exists(ROOT.DS.'web'.DS.implode('/',$url)) && !is_dir(ROOT.DS.'web'.DS.implode('/',$url)))
|
if (php_sapi_name() == 'cli-server' && file_exists(ROOT . DS . 'web' . DS . implode('/', $url)) && !is_dir(ROOT . DS . 'web' . DS . implode('/', $url)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
switch($url[0])
|
switch ($url[0]) {
|
||||||
{
|
|
||||||
case 'api':
|
case 'api':
|
||||||
$target = substr($_SERVER['REQUEST_URI'],5);
|
$target = substr($_SERVER['REQUEST_URI'], 5);
|
||||||
if(!$target || !filter_var($target, FILTER_VALIDATE_URL))
|
if (!$target || !filter_var($target, FILTER_VALIDATE_URL))
|
||||||
$target = $_REQUEST['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');
|
header('HTTP/1.0 400 Bad Request');
|
||||||
echo 'Invalid URL';
|
echo 'Invalid URL';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
$ip = getUserIP();
|
||||||
|
|
||||||
$viewport = $_REQUEST['viewport'];
|
$viewport = $_REQUEST['viewport'];
|
||||||
$js = $_REQUEST['js']=='false'?false:true;
|
$js = $_REQUEST['js'] == 'false' ? false : true;
|
||||||
|
|
||||||
$serverUrl = 'http://localhost:4444';
|
$serverUrl = 'http://localhost:4444';
|
||||||
$options = new \Facebook\WebDriver\Chrome\ChromeOptions();
|
$options = new \Facebook\WebDriver\Chrome\ChromeOptions();
|
||||||
@ -40,27 +41,31 @@ switch($url[0])
|
|||||||
$capabilities->setCapability(\Facebook\WebDriver\Chrome\ChromeOptions::CAPABILITY, $options);
|
$capabilities->setCapability(\Facebook\WebDriver\Chrome\ChromeOptions::CAPABILITY, $options);
|
||||||
|
|
||||||
//disable javascript if $js is false
|
//disable javascript if $js is false
|
||||||
if(!$js)
|
if (!$js)
|
||||||
$capabilities->setCapability('javascriptEnabled', false);
|
$capabilities->setCapability('javascriptEnabled', false);
|
||||||
|
|
||||||
$driver = RemoteWebDriver::create($serverUrl, $capabilities);
|
|
||||||
|
|
||||||
$driver->get($target);
|
try {
|
||||||
|
$driver = RemoteWebDriver::create($serverUrl, $capabilities);
|
||||||
|
$driver->get($target);
|
||||||
|
//hide scroll bars
|
||||||
|
$driver->executeScript('document.body.style.overflow = "hidden";');
|
||||||
|
|
||||||
//hide scroll bars
|
//set screenshot size to 1920x1080
|
||||||
$driver->executeScript('document.body.style.overflow = "hidden";');
|
//$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension(1024, 768));
|
||||||
|
//if $viewport is set, set window size
|
||||||
//set screenshot size to 1920x1080
|
if ($viewport) {
|
||||||
//$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension(1024, 768));
|
$viewport = explode('x', $viewport);
|
||||||
//if $viewport is set, set window size
|
$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension($viewport[0], $viewport[1]));
|
||||||
if($viewport)
|
} else {
|
||||||
{
|
$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension(1024, 768));
|
||||||
$viewport = explode('x',$viewport);
|
}
|
||||||
$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension($viewport[0], $viewport[1]));
|
addToLog("$ip\tRequested $target with viewport " . implode('x', $viewport) . " and js " . ($js ? 'enabled' : 'disabled'));
|
||||||
}
|
} catch (Exception $e) {
|
||||||
else
|
header('HTTP/1.0 500 Internal Server Error');
|
||||||
{
|
addToLog("$ip\tRequested $target but resulted in error:\t" . $e->getMessage());
|
||||||
$driver->manage()->window()->setSize(new \Facebook\WebDriver\WebDriverDimension(1024, 768));
|
echo 'Error: ' . $e->getMessage();
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// take screenshot and save to file
|
// take screenshot and save to file
|
||||||
@ -68,7 +73,7 @@ switch($url[0])
|
|||||||
header('Content-Type: image/png');
|
header('Content-Type: image/png');
|
||||||
echo $driver->takeScreenshot();
|
echo $driver->takeScreenshot();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
echo renderTemplate('index.html.php');
|
echo renderTemplate('index.html.php');
|
||||||
break;
|
break;
|
||||||
|