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

194 lines
6.0KB

  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_soft_lang;
  28. $restr = '';
  29. if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
  30. if ($cfg_soft_lang == "utf-8") {
  31. $str = gb2utf8($str);
  32. }
  33. $client = new DedeBizClient();
  34. $data = $client->Pinyin($str, "");
  35. $restr = $data->data;
  36. $client->Close();
  37. } else {
  38. $str = trim($str);
  39. $slen = strlen($str);
  40. if ($slen < 2) {
  41. return $str;
  42. }
  43. if (@count($pinyins) == 0) {
  44. $fp = fopen(DEDEINC.'/data/pinyin.dat', 'r');
  45. while (!feof($fp)) {
  46. $line = trim(fgets($fp));
  47. $pinyins[$line[0].$line[1]] = substr($line, 3, strlen($line) - 3);
  48. }
  49. fclose($fp);
  50. }
  51. for ($i = 0; $i < $slen; $i++) {
  52. if (ord($str[$i]) > 0x80) {
  53. $c = $str[$i].$str[$i + 1];
  54. $i++;
  55. if (isset($pinyins[$c])) {
  56. if ($ishead == 0) {
  57. $restr .= $pinyins[$c];
  58. } else {
  59. $restr .= $pinyins[$c][0];
  60. }
  61. } else {
  62. $restr .= "_";
  63. }
  64. } else if (preg_match("/[a-z0-9]/i", $str[$i])) {
  65. $restr .= $str[$i];
  66. } else {
  67. $restr .= "_";
  68. }
  69. }
  70. if ($isclose == 0) {
  71. unset($pinyins);
  72. }
  73. }
  74. return $restr;
  75. }
  76. /**
  77. * 创建目录
  78. *
  79. * @access public
  80. * @param string $spath 目录名称
  81. * @return string
  82. */
  83. function SpCreateDir($spath)
  84. {
  85. global $cfg_dir_purview, $cfg_basedir, $cfg_ftp_mkdir, $isSafeMode;
  86. if ($spath == '') {
  87. return true;
  88. }
  89. $flink = false;
  90. $truepath = $cfg_basedir;
  91. $truepath = str_replace("\\", "/", $truepath);
  92. $spaths = explode("/", $spath);
  93. $spath = "";
  94. foreach ($spaths as $spath) {
  95. if ($spath == "") {
  96. continue;
  97. }
  98. $spath = trim($spath);
  99. $truepath .= "/".$spath;
  100. if (!is_dir($truepath) || !is_writeable($truepath)) {
  101. if (!is_dir($truepath)) {
  102. $isok = MkdirAll($truepath, $cfg_dir_purview);
  103. } else {
  104. $isok = ChmodAll($truepath, $cfg_dir_purview);
  105. }
  106. if (!$isok) {
  107. echo "创建或修改目录<span class='text-primary'>".$truepath."</span>失败";
  108. CloseFtp();
  109. return false;
  110. }
  111. }
  112. }
  113. CloseFtp();
  114. return true;
  115. }
  116. function jsScript($js)
  117. {
  118. $out = "<script>";
  119. $out .= "//<![CDATA[\n";
  120. $out .= $js;
  121. $out .= "\n//]]>";
  122. $out .= "</script>\n";
  123. return $out;
  124. }
  125. /**
  126. * 获取修改器
  127. *
  128. * @access public
  129. * @param string $fname 表单名称
  130. * @param string $fvalue 表单值
  131. * @param string $nheight 文档高度
  132. * @param string $etype 修改器类型
  133. * @param string $gtype 获取值类型
  134. * @param string $isfullpage 是否全屏
  135. * @return string
  136. */
  137. function SpGetEditor($fname, $fvalue, $nheight = "350", $etype = "Basic", $gtype = "print", $isfullpage = "false", $bbcode = false)
  138. {
  139. global $cfg_ckeditor_initialized;
  140. if (!isset($GLOBALS['cfg_html_editor'])) {
  141. $GLOBALS['cfg_html_editor'] = 'fck';
  142. }
  143. if ($gtype == "") {
  144. $gtype = "print";
  145. }
  146. if ($GLOBALS['cfg_html_editor'] == 'ckeditor') {
  147. $addConfig = "";
  148. if (defined("DEDEADMIN")) {
  149. $emoji = "";
  150. if ($GLOBALS['cfg_db_language']=="utf8mb4") {
  151. $emoji = ",emoji";
  152. }
  153. $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'}";
  154. }
  155. $code = <<<EOT
  156. <script src="{$GLOBALS['cfg_static_dir']}/ckeditor/ckeditor.js"></script>
  157. <textarea id="{$fname}" name="{$fname}" rows="8" cols="60">{$fvalue}</textarea>
  158. <script>var editor = CKEDITOR.replace('{$fname}'{$addConfig});</script>
  159. EOT;
  160. if ($gtype == "print") {
  161. echo $code;
  162. } else {
  163. return $code;
  164. }
  165. }
  166. }
  167. /**
  168. * 获取更新信息
  169. *
  170. * @return void
  171. */
  172. function SpGetNewInfo()
  173. {
  174. global $cfg_version_detail, $dsql;
  175. $nurl = $_SERVER['HTTP_HOST'];
  176. if (preg_match("#[a-z\-]{1,}\.[a-z]{2,}#i", $nurl)) {
  177. $nurl = urlencode($nurl);
  178. } else {
  179. $nurl = "test";
  180. }
  181. $phpv = phpversion();
  182. $sp_os = PHP_OS;
  183. $mysql_ver = $dsql->GetVersion();
  184. $add_query = '';
  185. $query = "SELECT COUNT(*) AS dd FROM `#@__member` ";
  186. $row1 = $dsql->GetOne($query);
  187. if ($row1) $add_query .= "&mcount={$row1['dd']}";
  188. $query = "SELECT COUNT(*) AS dd FROM `#@__arctiny` ";
  189. $row2 = $dsql->GetOne($query);
  190. if ($row2) $add_query .= "&acount={$row2['dd']}";
  191. $offUrl = DEDEBIZURL."/version?version={$cfg_version_detail}&formurl={$nurl}&phpver={$phpv}&os={$sp_os}&mysqlver={$mysql_ver}{$add_query}";
  192. return $offUrl;
  193. }
  194. ?>