Created
September 2, 2013 21:23
-
-
Save kezz/6417394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| error_reporting(E_ALL); | |
| ini_set('display_errors', 1); | |
| ini_set('allow_url_fopen', 1); | |
| include 'resources/php/pastebin.php'; | |
| if(empty($_GET["p"]) == false) { | |
| create_image(); | |
| exit(); | |
| } | |
| //Send a generated image to the browser | |
| function create_image() | |
| { | |
| $web = $_GET["p"]; | |
| $array = file("http://pastebin.com/raw.php?i={$web}", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); | |
| //the writing in large text | |
| $header = $array[0]; | |
| //description line 1 | |
| $subheader = $array[1]; | |
| //description line 2 | |
| $details = $array[2]; | |
| //description line 3 placeholder | |
| $quote = $array[rand(3, sizeof($array))]; | |
| //Set the image width and height - you shouldn't put it much above this to comply with Bukkit T&C | |
| $width = 700; | |
| $height = 100; | |
| //Create the image resource | |
| $image = ImageCreate($width, $height); | |
| //enable antialiasing | |
| imageantialias($image , true); | |
| //all the possible background colours, represented as array(RED, GREEN, BLUE) | |
| $bgpos = array( | |
| array(26, 188, 156), | |
| array(46, 204, 113), | |
| array(52, 152, 219), | |
| array(155, 89, 182), | |
| array(52, 73, 94), | |
| array(22, 160, 133), | |
| array(39, 174, 96), | |
| array(41, 128, 185), | |
| array(142, 68, 173), | |
| array(44, 62, 80), | |
| array(241, 196, 15), | |
| array(230, 126, 34), | |
| array(231, 76, 60), | |
| array(149, 165, 166), | |
| array(243, 156, 18), | |
| array(211, 84, 0), | |
| array(192, 57, 43), | |
| array(127, 140, 141) | |
| ); | |
| //gets a random colour [array] | |
| $chosen = $bgpos[array_rand($bgpos)]; | |
| /* | |
| Background Colour | |
| Converts $chosen to useable colour | |
| */ | |
| $bg = ImageColorAllocate($image, $chosen[0], $chosen[1], $chosen[2]); | |
| /* | |
| Foreground Colour, the Colour of text | |
| Default is white | |
| */ | |
| $fg = ImageColorAllocate($image, 255, 255, 255); | |
| //Make the background $bg | |
| ImageFill($image, 0, 0, $bg); | |
| $fontpath = "resources/fonts/Ubuntu-M.ttf";//the directory of the font to use | |
| //Draw $header | |
| //image, font size, angle, x, y, colour, font, text | |
| imagettftext($image, 32, 0, 32, 64, $fg, $fontpath, $header); | |
| //gets the x offset of the line and later, the bar | |
| $box = imagettfbbox (32, 0, $fontpath, $header); | |
| $offset = $box[4]+64; | |
| //draw seperater line | |
| imagefilledrectangle($image, $offset, 0, $offset+5, 100, $fg); | |
| $offset += 37;//description lines x value | |
| imagettftext($image, 10, 0, $offset, 38, $fg, $fontpath, $subheader); | |
| imagettftext($image, 10, 0, $offset, 50, $fg, $fontpath, $details); | |
| imagettftext($image, 10, 0, $offset, 64, $fg, $fontpath, $quote); | |
| //Tell the browser what kind of file is come in (seems to work, png didn't) | |
| header("Content-Type: image/jpeg"); | |
| //Output the newly created image in png format | |
| ImagePng($image); | |
| //Free up resources | |
| ImageDestroy($image); | |
| } | |
| ?> | |
| <html> | |
| <head> | |
| <title>Dynamic Signature Generator</title> | |
| <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"> | |
| <script type="text/javascript"> | |
| function goToSig() { | |
| document.getElementById("url").innerHTML = "Your new signature can be found <a href=\"http://kieranwallbanks.me/sig.php?p=<?php echo getPasteId(\"" + document.getElementById("header").value + "\r\n" + document.getElementById("subheader").value + "\r\n" + document.getElementById("details").value + "\r\n" + document.getElementById("quotes").value + "\"); ?>\">here</a>"; | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <div align="center" class="input-large"> | |
| <h1>Dynamic Signature Generator</h1> | |
| <h2>By Kezz101 and Hoolean</h2> | |
| <br /> | |
| <div id="url"></div> | |
| <form> | |
| <table> | |
| <tr> | |
| <td>Header:</td> | |
| <td><input type="text" id="header"/></td> | |
| </tr> | |
| <tr> | |
| <td>Subheader:</td> | |
| <td><input type="text" id="subheader" /></td> | |
| </tr> | |
| <tr> | |
| <td>Details:</td> | |
| <td><input type="text" id="details" /></td> | |
| </tr> | |
| </table> | |
| Quotes <br /> | |
| <div style="font-size: 75%">Separate quotes by placing them on a new line</div> | |
| <textarea id="quotes" rows="15" cols="70"></textarea> | |
| </form> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment