国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.6KB

  1. <?php
  2. /**
  3. * 图片水印
  4. *
  5. * @version $Id: sys_info_mark.php 1 22:28 2010年7月20日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('sys_Edit');
  13. require_once(DEDEINC."/image.func.php");
  14. if ($cfg_photo_support == '') {
  15. echo "您的系统没安装GD库,不允许使用本功能";
  16. exit();
  17. }
  18. $ImageWaterConfigFile = DEDEDATA."/mark/inc_photowatermark_config.php";
  19. if (empty($action)) $action = "";
  20. $allow_mark_types = array(
  21. 'image/gif',
  22. 'image/xpng',
  23. 'image/png',
  24. );
  25. if ($action == "save") {
  26. $vars = array('photo_markup', 'photo_markdown', 'photo_marktype', 'photo_wwidth', 'photo_wheight', 'photo_waterpos', 'photo_watertext', 'photo_fontsize', 'photo_fontcolor', 'photo_marktrans', 'photo_diaphaneity');
  27. $configstr = $shortname = "";
  28. foreach ($vars as $v) {
  29. $tmp = stripslashes(${'get_'.$v});
  30. ${$v} = addslashes(str_replace("'", "", $tmp));
  31. $configstr .= "\${$v} = '".${$v}."';\r\n";
  32. }
  33. if (is_uploaded_file($newimg)) {
  34. $imgfile_type = strtolower(trim($newimg_type));
  35. if (!in_array($imgfile_type, $allow_mark_types)) {
  36. ShowMsg("上传的图片格式错误,请使用 gif、png格式的其中一种", "-1");
  37. exit();
  38. }
  39. if ($imgfile_type == 'image/xpng' || $imgfile_type == 'image/png') {
  40. $shortname = ".png";
  41. } else if ($imgfile_type == 'image/gif') {
  42. $shortname = ".gif";
  43. } else {
  44. ShowMsg("水印图片仅支持gif、png格式的其中一种", "-1");
  45. exit;
  46. }
  47. $photo_markimg = 'mark'.$shortname;
  48. $mime = get_mime_type($newimg);
  49. if (preg_match("#^unknow#", $mime)) {
  50. ShowMsg("系统不支持fileinfo组件,建议php.ini中开启", -1);
  51. exit;
  52. }
  53. if (!preg_match("#^(image|video|audio|application)#i", $mime)) {
  54. ShowMsg("仅支持媒体文件及应用程序上传", -1);
  55. exit;
  56. }
  57. @move_uploaded_file($newimg, DEDEDATA."/mark/".$photo_markimg);
  58. }
  59. $configstr .= "\$photo_markimg = '{$photo_markimg}';\r\n";
  60. $configstr = "<"."?php\r\n".$configstr."?".">\r\n";
  61. $fp = fopen($ImageWaterConfigFile, "w") or die("写入文件 $ImageWaterConfigFile 失败,请检查权限");
  62. fwrite($fp, $configstr);
  63. fclose($fp);
  64. echo "<script>alert('修改配置成功');</script>\r\n";
  65. }
  66. require_once($ImageWaterConfigFile);
  67. include DedeInclude('templets/sys_info_mark.htm');