diff --git a/.devcontainer/start.sh b/.devcontainer/start.sh index 1d58c08..82ccbca 100644 --- a/.devcontainer/start.sh +++ b/.devcontainer/start.sh @@ -14,7 +14,8 @@ cd ${WORKSPACE_PATH}/src composer install echo ' [+] Starting Chrome' -chromedriver --port=4444 & +cd /tmp +nohup chromedriver --port=4444 & chmod 777 ${WORKSPACE_PATH}/cache diff --git a/src/templates/index.html.php b/src/templates/index.html.php index 7b17238..2461452 100644 --- a/src/templates/index.html.php +++ b/src/templates/index.html.php @@ -50,7 +50,7 @@ -
+
@@ -58,7 +58,7 @@

http2pic


Loading..


- Give it a try! + Give it a try!
@@ -71,7 +71,7 @@

How the API works

-

/api.php?[OPTIONS]&url=[WEBSITE_URL]



+

/api/url=[WEBSITE_URL]&[OPTIONS]



@@ -90,12 +90,6 @@ The URL of the webpage you'd like to take a screenshot of. Make sure to encode the URL! url=http://xkcd.com - - width - WIDTH - Resizes the screenshot to a specified maximum width. Default value is the original size - width=400 - viewport WIDTHxHEIGHT @@ -104,33 +98,9 @@ js - yes|no + true|false Allows you to enable/disable JavaScript in the rendered Website. Default value: yes - js=yes - - - type - jpg|png - Sets the output file format of the rendered screenshot. Default value: jpg - type=png - - - onfail - [url of .jpg] - If the page can't be reached, this image will be displayed instead - /img/pagefailed.jpg - - - ondomainfail - [url of .jpg] - If the web server can't be reached, this image will be displayed instead - /img/domainfailed.jpg - - - cache - [any alphanumeric string] - If provided, caches the rendered image (based on the URL) so it loads faster on next request. The same cache id with the same url will return the cached image. Change cache id to re-render - f01d0 + js=false @@ -146,11 +116,10 @@

 <?php
     $url = 'http://www.xkcd.com';
-    $query = 'type=jpg&viewport=1200x330&url='.rawurlencode($url);
-    $img="/api.php?$query";
+    $query = 'viewport=1200x330&url='.rawurlencode($url);
+    $img="/api/?$query";
 
     echo "<img src='$img' />";
-?>
                         

@@ -161,7 +130,7 @@

 <?php
     $targeturl = 'http://www.xkcd.com';
-    $url = '/api.php?url='.rawurlencode($targeturl);
+    $url = '/api/?url='.rawurlencode($targeturl);
 	    
     $ch = curl_init($url);
     $fp = fopen('xkcd.jpg', 'wb');
@@ -170,7 +139,6 @@
     curl_exec($ch);
     curl_close($ch);
     fclose($fp);
-?>
                         

diff --git a/web/index.php b/web/index.php index d4eaa60..73d0b41 100644 --- a/web/index.php +++ b/web/index.php @@ -21,7 +21,7 @@ switch($url[0]) { case 'api': $target = substr($_SERVER['REQUEST_URI'],5); - if(!$target) + if(!$target || !filter_var($target, FILTER_VALIDATE_URL)) $target = $_REQUEST['url']; $viewport = $_REQUEST['viewport']; $js = $_REQUEST['js']=='false'?false:true; diff --git a/web/js/http2pic.js b/web/js/http2pic.js index 5e77c8e..85fdfc9 100644 --- a/web/js/http2pic.js +++ b/web/js/http2pic.js @@ -3,7 +3,8 @@ $(function() { { $("#showcase_button").attr("disabled","true"); var urlenc = encodeURIComponent(url); - var imageURL = "api.php?js=no&cache=1&viewport=1200x330&url="+urlenc; + var host = location.protocol + '//' + location.host; + var imageURL = host+"/api/?js=false&viewport=1200x330&url="+urlenc; //$("#intro-header").css('background-image', 'url(\'/img/loading.gif\')'); $("#loading").show();