Skip to content

Instantly share code, notes, and snippets.

@url2png
Created July 28, 2011 15:53
Show Gist options
  • Save url2png/1111801 to your computer and use it in GitHub Desktop.
Save url2png/1111801 to your computer and use it in GitHub Desktop.
dom2png (url2png)
<?php
# =============================
# = DOM2PNG Proof of Concept =
# =============================
function url2png($url,$size,$api_key,$shared_secret)
{
global $base;
global $key;
global $string;
$url = preg_replace('/^http:\/\//','',$url); # *yawn*
$url = str_replace('%','%25',$url);
$url = str_replace(' ','%20',$url);
$url = str_replace('&','%26',$url);
$url = str_replace('#','%23',$url);
$url = str_replace('?','%3F',$url);
$magical_hash = md5("$shared_secret+$url");
return "http://api.url2png.com/v3/$api_key/$magical_hash/$size/$url";
}
$key = sha1(time());
$_POST['dom'] = (empty($_POST['dom'])) ? 'foo' : $_POST['dom'];
@file_put_contents("./tmp/" . $key . ".html", urldecode($_POST['dom']));
echo url2png("http://url2png.com/dom2png/tmp/$key.html","300x300","DOM2PNG-APIKEY","DOM2PNG-SECRETKEY");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment