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

240 lines
7.4KB

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