Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['url'])) {
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, 'http://www.google.com/url?q='.urlencode($_POST['url']));
- curl_setopt($curl, CURLOPT_HEADER, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($curl, CURLOPT_SSLVERSION, 3);
- curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21");
- $page = curl_exec($curl);
- $dom = new domDocument;
- @$dom->loadHTML($page);
- $dom->preserveWhiteSpace = false;
- $a = $dom->getElementsByTagName('a');
- echo 'http://www.google.com' . $a->item(0)->getAttribute('href');
- } else {
- ?>
- <form method="POST">
- Url: <input name="url" />
- <br /><input type="submit" value="Generate url!" />
- </form>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement