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

195 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 GNU GPL v2 (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;
  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. return false;
  109. }
  110. }
  111. }
  112. return true;
  113. }
  114. function jsScript($js)
  115. {
  116. $out = "<script>";
  117. $out .= "//<![CDATA[\n";
  118. $out .= $js;
  119. $out .= "\n//]]>";
  120. $out .= "</script>\n";
  121. return $out;
  122. }
  123. /**
  124. * 获取富文本
  125. *
  126. * @access public
  127. * @param string $fname 表单名称
  128. * @param string $fvalue 表单值
  129. * @param string $nheight 文档高度
  130. * @param string $etype 修改器类型
  131. * @param string $gtype 获取值类型
  132. * @param string $isfullpage 是否全屏
  133. * @return string
  134. */
  135. function SpGetEditor($fname, $fvalue, $nheight = "350", $etype = "Basic", $gtype = "print", $isfullpage = "false", $bbcode = false)
  136. {
  137. global $cfg_ckeditor_initialized;
  138. if (!isset($GLOBALS['cfg_html_editor'])) {
  139. $GLOBALS['cfg_html_editor'] = 'fck';
  140. }
  141. if ($gtype == "") {
  142. $gtype = "print";
  143. }
  144. if ($GLOBALS['cfg_html_editor'] == 'ckeditor') {
  145. $addConfig = "";
  146. if (defined("DEDEADMIN")) {
  147. $emoji = "";
  148. if ($GLOBALS['cfg_db_language']=="utf8mb4") {
  149. $emoji = ",emoji";
  150. }
  151. $addConfig = ",{allowedContent:true,pasteFilter:null,filebrowserImageUploadUrl:'./dialog/select_images_post.php',filebrowserUploadUrl:'./dialog/select_media_post.php?ck=1',extraPlugins:'html5video,html5audio,dedepagebreak,ddfilebrowser,mimage,textindent,tabletools,tableresize,tableselection,codesnippet{$emoji}',codeSnippet_theme: 'default'}";
  152. }
  153. if (defined('DEDEUSER')) {
  154. $addConfig = ",{filebrowserImageUploadUrl:'api.php?action=upload&type=litpic&ck=1',filebrowserUploadUrl:'api.php?action=upload&type=media&ck=1',extraPlugins:'html5video,html5audio,textindent',filebrowserImageBrowseDisabled:true}";
  155. }
  156. $code = <<<EOT
  157. <script src="{$GLOBALS['cfg_static_dir']}/ckeditor/ckeditor.js"></script>
  158. <textarea id="{$fname}" name="{$fname}">{$fvalue}</textarea>
  159. <script>var editor = CKEDITOR.replace('{$fname}'{$addConfig});</script>
  160. EOT;
  161. if ($gtype == "print") {
  162. echo $code;
  163. } else {
  164. return $code;
  165. }
  166. }
  167. }
  168. /**
  169. * 获取更新信息
  170. *
  171. * @return void
  172. */
  173. function SpGetNewInfo()
  174. {
  175. global $cfg_version_detail, $dsql;
  176. $nurl = $_SERVER['HTTP_HOST'];
  177. if (preg_match("#[a-z\-]{1,}\.[a-z]{2,}#i", $nurl)) {
  178. $nurl = urlencode($nurl);
  179. } else {
  180. $nurl = "test";
  181. }
  182. $phpv = phpversion();
  183. $sp_os = PHP_OS;
  184. $mysql_ver = $dsql->GetVersion();
  185. $add_query = '';
  186. $query = "SELECT COUNT(*) AS dd FROM `#@__member` ";
  187. $row1 = $dsql->GetOne($query);
  188. if ($row1) $add_query .= "&mcount={$row1['dd']}";
  189. $query = "SELECT COUNT(*) AS dd FROM `#@__arctiny` ";
  190. $row2 = $dsql->GetOne($query);
  191. if ($row2) $add_query .= "&acount={$row2['dd']}";
  192. $offUrl = DEDEBIZURL."/version?version={$cfg_version_detail}&formurl={$nurl}&phpver={$phpv}&os={$sp_os}&mysqlver={$mysql_ver}{$add_query}";
  193. return $offUrl;
  194. }
  195. ?>