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

261 lines
7.0KB

  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) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.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. $restr = '';
  24. $str = trim($str);
  25. $slen = strlen($str);
  26. if($slen < 2)
  27. {
  28. return $str;
  29. }
  30. if(@count($pinyins) == 0)
  31. {
  32. $fp = fopen(DEDEINC.'/data/pinyin.dat', 'r');
  33. while(!feof($fp))
  34. {
  35. $line = trim(fgets($fp));
  36. $pinyins[$line[0].$line[1]] = substr($line, 3, strlen($line)-3);
  37. }
  38. fclose($fp);
  39. }
  40. for($i=0; $i<$slen; $i++)
  41. {
  42. if(ord($str[$i])>0x80)
  43. {
  44. $c = $str[$i].$str[$i+1];
  45. $i++;
  46. if(isset($pinyins[$c]))
  47. {
  48. if($ishead==0)
  49. {
  50. $restr .= $pinyins[$c];
  51. }
  52. else
  53. {
  54. $restr .= $pinyins[$c][0];
  55. }
  56. }else
  57. {
  58. $restr .= "_";
  59. }
  60. }else if( preg_match("/[a-z0-9]/i", $str[$i]) )
  61. {
  62. $restr .= $str[$i];
  63. }
  64. else
  65. {
  66. $restr .= "_";
  67. }
  68. }
  69. if($isclose==0)
  70. {
  71. unset($pinyins);
  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. {
  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. {
  96. if($spath=="")
  97. {
  98. continue;
  99. }
  100. $spath = trim($spath);
  101. $truepath .= "/".$spath;
  102. if(!is_dir($truepath) || !is_writeable($truepath))
  103. {
  104. if(!is_dir($truepath))
  105. {
  106. $isok = MkdirAll($truepath,$cfg_dir_purview);
  107. }
  108. else
  109. {
  110. $isok = ChmodAll($truepath,$cfg_dir_purview);
  111. }
  112. if(!$isok)
  113. {
  114. echo "创建或修改目录:".$truepath." 失败!<br>";
  115. CloseFtp();
  116. return false;
  117. }
  118. }
  119. }
  120. CloseFtp();
  121. return true;
  122. }
  123. function jsScript($js)
  124. {
  125. $out = "<script type=\"text/javascript\">";
  126. $out .= "//<![CDATA[\n";
  127. $out .= $js;
  128. $out .= "\n//]]>";
  129. $out .= "</script>\n";
  130. return $out;
  131. }
  132. /**
  133. * 获取编辑器
  134. *
  135. * @access public
  136. * @param string $fname 表单名称
  137. * @param string $fvalue 表单值
  138. * @param string $nheight 内容高度
  139. * @param string $etype 编辑器类型
  140. * @param string $gtype 获取值类型
  141. * @param string $isfullpage 是否全屏
  142. * @return string
  143. */
  144. function SpGetEditor($fname,$fvalue,$nheight="350",$etype="Basic",$gtype="print",$isfullpage="false",$bbcode=false)
  145. {
  146. global $cfg_ckeditor_initialized;
  147. if(!isset($GLOBALS['cfg_html_editor']))
  148. {
  149. $GLOBALS['cfg_html_editor']='fck';
  150. }
  151. if($gtype=="")
  152. {
  153. $gtype = "print";
  154. }
  155. if($GLOBALS['cfg_html_editor']=='fck')
  156. {
  157. require_once(DEDEINC.'/FCKeditor/fckeditor.php');
  158. $fck = new FCKeditor($fname);
  159. $fck->BasePath = $GLOBALS['cfg_cmspath'].'/include/FCKeditor/' ;
  160. $fck->Width = '100%' ;
  161. $fck->Height = $nheight ;
  162. $fck->ToolbarSet = $etype ;
  163. $fck->Config['FullPage'] = $isfullpage;
  164. if($GLOBALS['cfg_fck_xhtml']=='Y')
  165. {
  166. $fck->Config['EnableXHTML'] = 'true';
  167. $fck->Config['EnableSourceXHTML'] = 'true';
  168. }
  169. $fck->Value = $fvalue ;
  170. if($gtype=="print")
  171. {
  172. $fck->Create();
  173. }
  174. else
  175. {
  176. return $fck->CreateHtml();
  177. }
  178. }
  179. else if($GLOBALS['cfg_html_editor']=='ckeditor')
  180. {
  181. $code = <<<EOT
  182. <script src="{$GLOBALS['cfg_static_dir']}/ckeditor/ckeditor.js"></script>
  183. <textarea id="{$fname}" name="{$fname}" rows="8" cols="60">{$fvalue}</textarea>
  184. <script>
  185. var editor = CKEDITOR.replace('{$fname}');
  186. </script>
  187. EOT;
  188. if($gtype=="print")
  189. {
  190. echo $code;
  191. }
  192. else
  193. {
  194. return $code;
  195. }
  196. } else {
  197. /*
  198. // ------------------------------------------------------------------------
  199. // 当前版本,暂时取消dedehtml编辑器的支持
  200. // ------------------------------------------------------------------------
  201. require_once(DEDEINC.'/htmledit/dede_editor.php');
  202. $ded = new DedeEditor($fname);
  203. $ded->BasePath = $GLOBALS['cfg_cmspath'].'/include/htmledit/' ;
  204. $ded->Width = '100%' ;
  205. $ded->Height = $nheight ;
  206. $ded->ToolbarSet = strtolower($etype);
  207. $ded->Value = $fvalue ;
  208. if($gtype=="print")
  209. {
  210. $ded->Create();
  211. }
  212. else
  213. {
  214. return $ded->CreateHtml();
  215. }
  216. */
  217. }
  218. }
  219. /**
  220. * 获取更新信息
  221. *
  222. * @return void
  223. */
  224. function SpGetNewInfo()
  225. {
  226. global $cfg_version,$dsql;
  227. $nurl = $_SERVER['HTTP_HOST'];
  228. if( preg_match("#[a-z\-]{1,}\.[a-z]{2,}#i",$nurl) ) {
  229. $nurl = urlencode($nurl);
  230. }
  231. else {
  232. $nurl = "test";
  233. }
  234. $phpv = phpversion();
  235. $sp_os = PHP_OS;
  236. $mysql_ver = $dsql->GetVersion();
  237. $seo_info = $dsql->GetOne("SELECT * FROM `#@__plus_seoinfo` ORDER BY id DESC");
  238. $add_query = '';
  239. if ( $seo_info )
  240. {
  241. $add_query .= "&alexa_num={$seo_info['alexa_num']}&alexa_area_num={$seo_info['alexa_area_num']}&baidu_count={$seo_info['baidu_count']}&sogou_count={$seo_info['sogou_count']}&haosou360_count={$seo_info['haosou360_count']}";
  242. }
  243. $query = " SELECT COUNT(*) AS dd FROM `#@__member` ";
  244. $row1 = $dsql->GetOne($query);
  245. if ( $row1 ) $add_query .= "&mcount={$row1['dd']}";
  246. $query = " SELECT COUNT(*) AS dd FROM `#@__arctiny` ";
  247. $row2 = $dsql->GetOne($query);
  248. if ( $row2 ) $add_query .= "&acount={$row2['dd']}";
  249. $offUrl = "http://new"."ver.a"."pi.de"."decms.com/index.php?c=info57&version={$cfg_version}&formurl={$nurl}&phpver={$phpv}&os={$sp_os}&mysqlver={$mysql_ver}{$add_query}";
  250. return $offUrl;
  251. }
  252. ?>