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

inc_fun_funAdmin.php 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. $addConfig = "";
  182. if (defined("DEDEADMIN")) {
  183. $addConfig = ",{filebrowserImageUploadUrl:'./dialog/select_images_post.php'}";
  184. }
  185. $code = <<<EOT
  186. <script src="{$GLOBALS['cfg_static_dir']}/ckeditor/ckeditor.js"></script>
  187. <textarea id="{$fname}" name="{$fname}" rows="8" cols="60">{$fvalue}</textarea>
  188. <script>
  189. var editor = CKEDITOR.replace('{$fname}'{$addConfig});
  190. </script>
  191. EOT;
  192. if($gtype=="print")
  193. {
  194. echo $code;
  195. }
  196. else
  197. {
  198. return $code;
  199. }
  200. } else {
  201. /*
  202. // ------------------------------------------------------------------------
  203. // 当前版本,暂时取消dedehtml编辑器的支持
  204. // ------------------------------------------------------------------------
  205. require_once(DEDEINC.'/htmledit/dede_editor.php');
  206. $ded = new DedeEditor($fname);
  207. $ded->BasePath = $GLOBALS['cfg_cmspath'].'/include/htmledit/' ;
  208. $ded->Width = '100%' ;
  209. $ded->Height = $nheight ;
  210. $ded->ToolbarSet = strtolower($etype);
  211. $ded->Value = $fvalue ;
  212. if($gtype=="print")
  213. {
  214. $ded->Create();
  215. }
  216. else
  217. {
  218. return $ded->CreateHtml();
  219. }
  220. */
  221. }
  222. }
  223. /**
  224. * 获取更新信息
  225. *
  226. * @return void
  227. */
  228. function SpGetNewInfo()
  229. {
  230. global $cfg_version,$dsql;
  231. $nurl = $_SERVER['HTTP_HOST'];
  232. if( preg_match("#[a-z\-]{1,}\.[a-z]{2,}#i",$nurl) ) {
  233. $nurl = urlencode($nurl);
  234. }
  235. else {
  236. $nurl = "test";
  237. }
  238. $phpv = phpversion();
  239. $sp_os = PHP_OS;
  240. $mysql_ver = $dsql->GetVersion();
  241. $seo_info = $dsql->GetOne("SELECT * FROM `#@__plus_seoinfo` ORDER BY id DESC");
  242. $add_query = '';
  243. if ( $seo_info )
  244. {
  245. $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']}";
  246. }
  247. $query = " SELECT COUNT(*) AS dd FROM `#@__member` ";
  248. $row1 = $dsql->GetOne($query);
  249. if ( $row1 ) $add_query .= "&mcount={$row1['dd']}";
  250. $query = " SELECT COUNT(*) AS dd FROM `#@__arctiny` ";
  251. $row2 = $dsql->GetOne($query);
  252. if ( $row2 ) $add_query .= "&acount={$row2['dd']}";
  253. $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}";
  254. return $offUrl;
  255. }
  256. ?>