Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "inc.php";
- /* Description Generation:
- * Generates a description based on a plugin name in the
- * form of a PNG image. Also shows version number.
- */
- $plugin = "";
- if(isset($_GET['plugin'])){
- $plugin = $_GET['plugin'];
- }
- $file = "plugin_".$plugin."/docs/image.txt";
- $fh = fopen($file, 'r');
- $lines = 0;
- $chars = 0;
- while($line = fgets($fh)){
- $lines ++;
- if(strlen($line)>$chars){
- $chars = strlen($line);
- }
- }
- fclose($fh);
- $errorFlag = "";
- if($lines == 0){
- $lines = 1;
- $errorFlag = "Plugin not found!";
- }
- $lineheight = 22;
- $charwidth = 8;
- $img = imagecreate($chars*$charwidth,$lines*$lineheight);
- $backgroundcolor = imagecolorallocate($img, 255, 255, 255);
- $text_colour = imagecolorallocate($img, 0, 0, 0);
- if(strlen($errorFlag)>0){
- imagestring($img, 3, 2, 2, $errorFlag, $text_colour);
- }else{
- $Y = 2;
- $fh = fopen($file, 'r');
- while($line = fgets($fh)){
- $line = str_replace("\r\n", "", $line);
- imagestring($img, 4, 2, $Y, $line, $text_colour);
- $Y = $Y + $lineheight;
- }
- fclose($fh);
- }
- header("Content-type: image/png");
- imagepng($img);
- imagedestroy($img);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment