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

243 lines
7.5KB

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