⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 9-9.php

📁 《php程序设计》的配套源码 《php程序设计》的配套源码 《php程序设计》的配套源码 《php程序设计》的配套源码
💻 PHP
字号:
<?php
  // bring in redirected URL parameters,if any
  parse_str($_SERVER['REDIRECT_QUERY_STRING']);
  $button_dir = '/buttons/';
  $url = $_SERVER['REDIRECT_URL'];
  $root = $_SERVER['DOCUMENT_ROOT'];

  // pick out the extension
  $ext = substr($url, strrpos($url, '.'));

  // remove directory and extension from $url string
  $file = substr($url, strlen($button_dir), -strlen($ext));

  // security - don't allow '..'in filename
  $file = str_replace('..', '', $file);

  // text to display in button
  $text = urldecode($file);

  // build image
  if (!isset($font)) $font = 'times';
  if (!isset($size)) $size = 12;

  $im = ImageCreateFromPNG('button.png');
  $tsize = ImageTTFBBox($size, 0, $font, $text);
  $dx = abs($tsize[2] - $tsize[0]);
  $dy = abs($tsize[5] - $tsize[3]);
  $x = (ImageSx($im)-$dx)/2;
  $y = (ImageSy($im)-$dy)/2 + $dy;
  $black = ImageColorAllocate($im, 0, 0, 0);
  ImageTTFText($im, $size, 0, $x, $y, -$black, $font, $text);

  // send and save the image
  header('Content-Type: image/png');
  ImagePNG($im);
  ImagePNG($im, $root . $button_dir . "$file.png");
  ImageDestroy($im);
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -