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

  1. <?php
  2. /**
  3. * 添加友情链接
  4. *
  5. * @version $id:friendlink_add.php 10:59 2010年7月13日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license GNU GPL v2 (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. }
  27. $imgurl = $imgurl."/".$filename;
  28. $mime = get_mime_type($logoimg);
  29. if (preg_match("#^unknow#", $mime)) {
  30. ShowMsg("系统不支持fileinfo组件,建议php.ini中开启", -1);
  31. exit;
  32. }
  33. if (!preg_match("#^image#i", $mime)) {
  34. ShowMsg("非图片格式文件,无法正常上传", -1);
  35. exit;
  36. }
  37. move_uploaded_file($logoimg, $cfg_basedir.$imgurl) or die("复制文件到".$cfg_basedir.$imgurl."失败");
  38. @unlink($logoimg);
  39. } else {
  40. $imgurl = $logo;
  41. }
  42. //强制检测会员友情链接分类是否数据结构不符
  43. if (empty($typeid) || preg_match("#[^0-9]#", $typeid)) {
  44. $typeid = 0;
  45. $dsql->ExecuteNoneQuery("ALTER TABLE `#@__flinktype` CHANGE `ID` `id` MEDIUMINT( 8 ) UNSIGNED DEFAULT NULL AUTO_INCREMENT;");
  46. }
  47. $sortrank = isset($sortrank)? intval($sortrank) : 1;
  48. $url = isset($url)? HtmlReplace($url, -1) : '';
  49. $imgurl = isset($imgurl)? HtmlReplace($imgurl, -1) : '';
  50. $webname = isset($webname)? HtmlReplace($webname, -1) : '';
  51. $msg = isset($msg)? HtmlReplace($msg, -1) : '';
  52. $email = isset($email)? HtmlReplace($email, -1) : '';
  53. $typeid = isset($typeid)? intval($typeid) : 0;
  54. $ischeck = isset($ischeck)? intval($ischeck) : 0;
  55. $query = "INSERT INTO `#@__flink` (sortrank,url,webname,logo,msg,email,typeid,dtime,ischeck) VALUES ('$sortrank','$url','$webname','$imgurl','$msg','$email','$typeid','$dtime','$ischeck'); ";
  56. $rs = $dsql->ExecuteNoneQuery($query);
  57. $burl = empty($_COOKIE['ENV_GOBACK_URL']) ? "friendlink_main.php" : $_COOKIE['ENV_GOBACK_URL'];
  58. if ($rs) {
  59. ShowMsg("成功添加一个链接", $burl, 0, 500);
  60. exit();
  61. } else {
  62. ShowMsg("添加链接时出错,原因:".$dsql->GetError(), "javascript:;");
  63. exit();
  64. }
  65. }
  66. include DedeInclude('templets/friendlink_add.htm');
  67. ?>