国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

275 satır
7.5KB

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