From 028a4b54f499cf1ec76d48bf6995e1d6a5eecfcf Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 13 Jan 2025 15:42:44 +0000 Subject: [PATCH] api preparations for rework --- .devcontainer/start.sh | 2 +- web/index.php | 40 ++++++---------------------------------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/.devcontainer/start.sh b/.devcontainer/start.sh index e32a137..1d58c08 100644 --- a/.devcontainer/start.sh +++ b/.devcontainer/start.sh @@ -20,4 +20,4 @@ chromedriver --port=4444 & chmod 777 ${WORKSPACE_PATH}/cache chmod 777 ${WORKSPACE_PATH}/logs -caddy run --config /etc/caddy/Caddyfile \ No newline at end of file +caddy start --config /etc/caddy/Caddyfile \ No newline at end of file diff --git a/web/index.php b/web/index.php index ceba72b..d4eaa60 100644 --- a/web/index.php +++ b/web/index.php @@ -19,13 +19,12 @@ if(php_sapi_name()=='cli-server' && file_exists(ROOT.DS.'web'.DS.implode('/',$ur switch($url[0]) { - case 'test': - $target = $_GET['url']; - $type = $_GET['type']; - $timeout = $_GET['timeout']; - $viewport = $_GET['viewport']; - $js = $_GET['js']=='false'?false:true; - $resizewidth = $_GET['width']; + case 'api': + $target = substr($_SERVER['REQUEST_URI'],5); + if(!$target) + $target = $_REQUEST['url']; + $viewport = $_REQUEST['viewport']; + $js = $_REQUEST['js']=='false'?false:true; $serverUrl = 'http://localhost:4444'; $options = new \Facebook\WebDriver\Chrome\ChromeOptions(); @@ -37,8 +36,6 @@ switch($url[0]) //disable javascript if $js is false if(!$js) $capabilities->setCapability('javascriptEnabled', false); - - $driver = RemoteWebDriver::create($serverUrl, $capabilities); @@ -66,31 +63,6 @@ switch($url[0]) echo $driver->takeScreenshot(); break; - case 'api': - $url = $_GET['url']; - $type = $_GET['type']; - $timeout = $_GET['timeout']; - $viewport = $_GET['viewport']; - $js = $_GET['js']; - $resizewidth = $_GET['width']; - $cache = $_GET['cache']; - $onfail = rawurldecode($_GET['onfail']); - - $params = array('url'=>trim($url), - 'type'=>$type, - 'timeout'=>$timeout, - 'viewport'=>$viewport, - 'js'=>$js, - 'resizewidth'=>$resizewidth, - 'cache'=>$cache, - 'onfail'=>$onfail); - - $http2pic = new http2pic($params); - - break; - case 'img': - - break; default: echo renderTemplate('index.html.php'); break;