Kezz101

Dynamic Signature v2.0

Nov 4th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.51 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 1);
  5. ini_set('allow_url_fopen', 1);
  6.  
  7. include 'resources/php/pastebin.php';
  8.  
  9.  
  10. if(empty($_GET["p"]) == false) {
  11.     create_image();
  12.     exit();
  13. }
  14.  
  15. if(empty($_POST["header"]) == false) {
  16.     create_link();
  17.     die();
  18. }
  19.  
  20. function create_link() {
  21.     $response = curl_exec($ch);
  22.     header('Location: http://kieranwallbanks.me/sig.php?p='.getPasteId($_POST["header"].PHP_EOL.$_POST["subheader"].PHP_EOL.$_POST["details"].PHP_EOL.$_POST["quotes"]));
  23. }
  24.  
  25. //Send a generated image to the browser
  26. function create_image()
  27. {
  28.     $web = $_GET["p"];
  29.     $array = file("http://pastebin.com/raw.php?i={$web}", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  30.  
  31.     //the writing in large text
  32.     $header = $array[0];
  33.     //description line 1
  34.     $subheader = $array[1];
  35.     //description line 2
  36.     $details = $array[2];
  37.     //description line 3 placeholder
  38.     $quote = $array[rand(3, sizeof($array))];
  39.  
  40.     //Set the image width and height - you shouldn't put it much above this to comply with Bukkit T&C
  41.     $width = 700;
  42.     $height = 100;  
  43.  
  44.     //Create the image resource
  45.     $image = ImageCreate($width, $height);  
  46.    
  47.     //enable antialiasing
  48.     imageantialias($image , true);
  49.  
  50.     //all the possible background colours, represented as array(RED, GREEN, BLUE)
  51.     $bgpos = array(
  52.    
  53.         array(26, 188, 156),
  54.         array(46, 204, 113),
  55.         array(52, 152, 219),
  56.         array(155, 89, 182),
  57.         array(52, 73, 94),
  58.         array(22, 160, 133),
  59.         array(39, 174, 96),
  60.         array(41, 128, 185),
  61.         array(142, 68, 173),
  62.         array(44, 62, 80),
  63.         array(241, 196, 15),
  64.         array(230, 126, 34),
  65.         array(231, 76, 60),
  66.         array(149, 165, 166),
  67.         array(243, 156, 18),
  68.         array(211, 84, 0),
  69.         array(192, 57, 43),
  70.         array(127, 140, 141)
  71.        
  72.     );
  73.    
  74.     //gets a random colour [array]
  75.     $chosen = $bgpos[array_rand($bgpos)];
  76.  
  77.     /*
  78.     Background Colour
  79.     Converts $chosen to useable colour
  80.     */
  81.     $bg = ImageColorAllocate($image, $chosen[0], $chosen[1], $chosen[2]);
  82.     /*
  83.     Foreground Colour, the Colour of text
  84.     Default is white
  85.     */
  86.     $fg = ImageColorAllocate($image, 255, 255, 255);
  87.  
  88.     //Make the background $bg
  89.     ImageFill($image, 0, 0, $bg);
  90.  
  91.     $fontpath = "resources/fonts/Ubuntu-M.ttf";//the directory of the font to use
  92.  
  93.     //Draw $header
  94.     //image, font size, angle, x, y, colour, font, text
  95.     imagettftext($image, 32, 0, 32, 64, $fg, $fontpath, $header);
  96.    
  97.     //gets the x offset of the line and later, the bar
  98.     $box = imagettfbbox (32, 0, $fontpath, $header);
  99.     $offset = $box[4]+64;
  100.    
  101.     //draw seperater line
  102.     imagefilledrectangle($image, $offset, 0, $offset+5, 100, $fg);
  103.    
  104.     $offset += 37;//description lines x value
  105.    
  106.     imagettftext($image, 10, 0, $offset, 38, $fg, $fontpath, $subheader);
  107.     imagettftext($image, 10, 0, $offset, 50, $fg, $fontpath, $details);
  108.     imagettftext($image, 10, 0, $offset, 64, $fg, $fontpath, $quote);
  109.  
  110.     //Tell the browser what kind of file is come in (seems to work, png didn't)
  111.     header("Content-Type: image/jpeg");
  112.  
  113.     //Output the newly created image in png format
  114.     ImagePng($image);
  115.    
  116.     //Free up resources
  117.     ImageDestroy($image);
  118.    
  119. }
  120. ?>
  121.  
  122. <html>
  123.   <head>
  124.     <title>Dynamic Signature Generator</title>
  125.     <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
  126.   </head>
  127.  
  128.   <body>
  129.     <div align="center" class="input-large">
  130.       <h1>Dynamic Signature Generator</h1>
  131.       <h2>By Kezz101 and Hoolean</h2>
  132.       <br />
  133.  
  134.       <div id="url"></div>
  135.  
  136.       <form action="http://kieranwallbanks.me/sig.php" method="post">
  137.         <table>
  138.           <tr>
  139.             <td>Header:</td>
  140.             <td><input type="text" id="header" name="header"/></td>
  141.           </tr>
  142.           <tr>
  143.             <td>Subheader:</td>
  144.             <td><input type="text" id="subheader" name="subheader"/></td>
  145.           </tr>
  146.           <tr>
  147.             <td>Details:</td>
  148.             <td><input type="text" id="details" name="details"/></td>
  149.           </tr>
  150.         </table>
  151.  
  152.         Quotes <br />
  153.         <div style="font-size: 75%">Separate quotes by placing them on a new line</div>
  154.         <textarea id="quotes" rows="15" cols="70" name="quotes"></textarea>
  155.  
  156.         <br />
  157.  
  158.         <button type="submit">Submit</button>
  159.       </form>
  160.     </div>
  161.   </body>
  162. </html>
Advertisement
Add Comment
Please, Sign In to add comment