国内流行的内容管理系统(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.

68 lines
2.8KB

  1. <?php
  2. /**
  3. * 友情链接添加
  4. *
  5. * @version $Id: friendlink_add.php 1 10:59 2010年7月13日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(dirname(__FILE__)."/config.php");
  12. CheckPurview('plus_友情链接模块');
  13. if (empty($dopost)) $dopost = "";
  14. if ($dopost == "add") {
  15. $dtime = time();
  16. if (is_uploaded_file($logoimg)) {
  17. $names = split("\.", $logoimg_name);
  18. $shortname = ".".$names[count($names) - 1];
  19. if (!preg_match("#(jpg|gif|png)$#", $shortname)) {
  20. $shortname = '.gif';
  21. }
  22. $filename = MyDate("ymdHis", time()).mt_rand(1000, 9999).$shortname;
  23. $imgurl = $cfg_medias_dir."/flink";
  24. if (!is_dir($cfg_basedir.$imgurl)) {
  25. MkdirAll($cfg_basedir.$imgurl, $cfg_dir_purview);
  26. CloseFtp();
  27. }
  28. $imgurl = $imgurl."/".$filename;
  29. $mime = get_mime_type($logoimg);
  30. if (preg_match("#^unknow#", $mime)) {
  31. ShowMsg("系统不支持fileinfo组件,建议php.ini中开启", -1);
  32. exit;
  33. }
  34. if (!preg_match("#^image#i", $mime)) {
  35. ShowMsg("非图片格式文件,无法正常上传", -1);
  36. exit;
  37. }
  38. move_uploaded_file($logoimg, $cfg_basedir.$imgurl) or die("复制文件到:".$cfg_basedir.$imgurl."失败");
  39. @unlink($logoimg);
  40. } else {
  41. $imgurl = $logo;
  42. }
  43. //强制检测用户友情链接分类是否数据结构不符
  44. if (empty($typeid) || preg_match("#[^0-9]#", $typeid)) {
  45. $typeid = 0;
  46. $dsql->ExecuteNoneQuery("ALTER TABLE `#@__flinktype` CHANGE `ID` `id` MEDIUMINT( 8 ) UNSIGNED DEFAULT NULL AUTO_INCREMENT; ");
  47. }
  48. $sortrank = isset($sortrank)? intval($sortrank) : 1;
  49. $url = isset($url)? HtmlReplace($url, -1) : '';
  50. $imgurl = isset($imgurl)? HtmlReplace($imgurl, -1) : '';
  51. $webname = isset($webname)? HtmlReplace($webname, -1) : '';
  52. $msg = isset($msg)? HtmlReplace($msg, -1) : '';
  53. $email = isset($email)? HtmlReplace($email, -1) : '';
  54. $typeid = isset($typeid)? intval($typeid) : 0;
  55. $ischeck = isset($ischeck)? intval($ischeck) : 0;
  56. $query = "INSERT INTO `#@__flink` (sortrank,url,webname,logo,msg,email,typeid,dtime,ischeck) VALUES ('$sortrank','$url','$webname','$imgurl','$msg','$email','$typeid','$dtime','$ischeck'); ";
  57. $rs = $dsql->ExecuteNoneQuery($query);
  58. $burl = empty($_COOKIE['ENV_GOBACK_URL']) ? "friendlink_main.php" : $_COOKIE['ENV_GOBACK_URL'];
  59. if ($rs) {
  60. ShowMsg("成功增加一个链接", $burl, 0, 500);
  61. exit();
  62. } else {
  63. ShowMsg("增加链接时出错,请向官方反馈,原因:".$dsql->GetError(), "javascript:;");
  64. exit();
  65. }
  66. }
  67. include DedeInclude('templets/friendlink_add.htm');
  68. ?>