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

197 lines
6.2KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 管理员后台基本函数
  5. *
  6. * @version $id:inc_fun_funAdmin.php 13:58 2010年7月5日 tianya $
  7. * @package DedeBIZ.Libraries
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. /**
  13. * 获取拼音信息
  14. *
  15. * @access public
  16. * @param string $str 字符串
  17. * @param int $ishead 是否为首字母
  18. * @param int $isclose 解析后是否释放资源
  19. * @return string
  20. */
  21. function SpGetPinyin($str, $ishead = 0, $isclose = 1)
  22. {
  23. global $pinyins;
  24. if ($pinyins==null) {
  25. $pinyins = array();
  26. }
  27. global $cfg_bizcore_appid, $cfg_bizcore_key, $cfg_bizcore_hostname, $cfg_bizcore_port;
  28. global $cfg_soft_lang;
  29. $restr = '';
  30. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  31. if ($cfg_soft_lang == "utf-8") {
  32. $str = gb2utf8($str);
  33. }
  34. $client = new DedeBizClient($cfg_bizcore_hostname, $cfg_bizcore_port);
  35. $client->appid = $cfg_bizcore_appid;
  36. $client->key = $cfg_bizcore_key;
  37. $data = $client->Pinyin($str, "");
  38. $restr = $data->data;
  39. $client->Close();
  40. } else {
  41. $str = trim($str);
  42. $slen = strlen($str);
  43. if ($slen < 2) {
  44. return $str;
  45. }
  46. if (@count($pinyins) == 0) {
  47. $fp = fopen(DEDEINC.'/data/pinyin.dat', 'r');
  48. while (!feof($fp)) {
  49. $line = trim(fgets($fp));
  50. $pinyins[$line[0].$line[1]] = substr($line, 3, strlen($line) - 3);
  51. }
  52. fclose($fp);
  53. }
  54. for ($i = 0; $i < $slen; $i++) {
  55. if (ord($str[$i]) > 0x80) {
  56. $c = $str[$i].$str[$i + 1];
  57. $i++;
  58. if (isset($pinyins[$c])) {
  59. if ($ishead == 0) {
  60. $restr .= $pinyins[$c];
  61. } else {
  62. $restr .= $pinyins[$c][0];
  63. }
  64. } else {
  65. $restr .= "_";
  66. }
  67. } else if (preg_match("/[a-z0-9]/i", $str[$i])) {
  68. $restr .= $str[$i];
  69. } else {
  70. $restr .= "_";
  71. }
  72. }
  73. if ($isclose == 0) {
  74. unset($pinyins);
  75. }
  76. }
  77. return $restr;
  78. }
  79. /**
  80. * 创建目录
  81. *
  82. * @access public
  83. * @param string $spath 目录名称
  84. * @return string
  85. */
  86. function SpCreateDir($spath)
  87. {
  88. global $cfg_dir_purview, $cfg_basedir, $cfg_ftp_mkdir, $isSafeMode;
  89. if ($spath == '') {
  90. return true;
  91. }
  92. $flink = false;
  93. $truepath = $cfg_basedir;
  94. $truepath = str_replace("\\", "/", $truepath);
  95. $spaths = explode("/", $spath);
  96. $spath = "";
  97. foreach ($spaths as $spath) {
  98. if ($spath == "") {
  99. continue;
  100. }
  101. $spath = trim($spath);
  102. $truepath .= "/".$spath;
  103. if (!is_dir($truepath) || !is_writeable($truepath)) {
  104. if (!is_dir($truepath)) {
  105. $isok = MkdirAll($truepath, $cfg_dir_purview);
  106. } else {
  107. $isok = ChmodAll($truepath, $cfg_dir_purview);
  108. }
  109. if (!$isok) {
  110. echo "创建或修改目录<span class='text-primary'>".$truepath."</span>失败<br>";
  111. CloseFtp();
  112. return false;
  113. }
  114. }
  115. }
  116. CloseFtp();
  117. return true;
  118. }
  119. function jsScript($js)
  120. {
  121. $out = "<script>";
  122. $out .= "//<![CDATA[\n";
  123. $out .= $js;
  124. $out .= "\n//]]>";
  125. $out .= "</script>\n";
  126. return $out;
  127. }
  128. /**
  129. * 获取修改器
  130. *
  131. * @access public
  132. * @param string $fname 表单名称
  133. * @param string $fvalue 表单值
  134. * @param string $nheight 文档高度
  135. * @param string $etype 修改器类型
  136. * @param string $gtype 获取值类型
  137. * @param string $isfullpage 是否全屏
  138. * @return string
  139. */
  140. function SpGetEditor($fname, $fvalue, $nheight = "350", $etype = "Basic", $gtype = "print", $isfullpage = "false", $bbcode = false)
  141. {
  142. global $cfg_ckeditor_initialized;
  143. if (!isset($GLOBALS['cfg_html_editor'])) {
  144. $GLOBALS['cfg_html_editor'] = 'fck';
  145. }
  146. if ($gtype == "") {
  147. $gtype = "print";
  148. }
  149. if ($GLOBALS['cfg_html_editor'] == 'ckeditor') {
  150. $addConfig = "";
  151. if (defined("DEDEADMIN")) {
  152. $emoji = "";
  153. if ($GLOBALS['cfg_db_language']=="utf8mb4") {
  154. $emoji = ",emoji";
  155. }
  156. $addConfig = ",{allowedContent:true,pasteFilter:null,filebrowserImageUploadUrl:'./dialog/select_images_post.php',filebrowserUploadUrl:'./dialog/select_media_post.php?ck=1',extraPlugins:'html5video,dedepagebreak,ddfilebrowser,mimage,textindent,codesnippet{$emoji}',codeSnippet_theme: 'default'}";
  157. }
  158. $code = <<<EOT
  159. <script src="{$GLOBALS['cfg_static_dir']}/ckeditor/ckeditor.js"></script>
  160. <textarea id="{$fname}" name="{$fname}" rows="8" cols="60">{$fvalue}</textarea>
  161. <script>var editor = CKEDITOR.replace('{$fname}'{$addConfig});</script>
  162. EOT;
  163. if ($gtype == "print") {
  164. echo $code;
  165. } else {
  166. return $code;
  167. }
  168. }
  169. }
  170. /**
  171. * 获取更新信息
  172. *
  173. * @return void
  174. */
  175. function SpGetNewInfo()
  176. {
  177. global $cfg_version_detail, $dsql;
  178. $nurl = $_SERVER['HTTP_HOST'];
  179. if (preg_match("#[a-z\-]{1,}\.[a-z]{2,}#i", $nurl)) {
  180. $nurl = urlencode($nurl);
  181. } else {
  182. $nurl = "test";
  183. }
  184. $phpv = phpversion();
  185. $sp_os = PHP_OS;
  186. $mysql_ver = $dsql->GetVersion();
  187. $add_query = '';
  188. $query = "SELECT COUNT(*) AS dd FROM `#@__member` ";
  189. $row1 = $dsql->GetOne($query);
  190. if ($row1) $add_query .= "&mcount={$row1['dd']}";
  191. $query = "SELECT COUNT(*) AS dd FROM `#@__arctiny` ";
  192. $row2 = $dsql->GetOne($query);
  193. if ($row2) $add_query .= "&acount={$row2['dd']}";
  194. $offUrl = DEDEBIZURL."/version?version={$cfg_version_detail}&formurl={$nurl}&phpver={$phpv}&os={$sp_os}&mysqlver={$mysql_ver}{$add_query}";
  195. return $offUrl;
  196. }
  197. ?>