rockClass.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <?php
  2. /**
  3. *****************************************************************
  4. * 联系QQ: 290802026 *
  5. * 版 本: V2.0 *
  6. * 开发者:雨中磐石(rainrock) *
  7. * 邮 箱: admin@rockoa.com *
  8. * 说 明: 基础操作类方法 *
  9. * 备 注: 未经允许不得商业出售,代码欢迎参考纠正 *
  10. *****************************************************************
  11. */
  12. final class rockClass
  13. {
  14. public $ip;
  15. public $host;
  16. public $url;
  17. public $win;
  18. public $web;
  19. public $unarr;
  20. public $now;
  21. public $date;
  22. public $jm;
  23. public $adminid;
  24. public $adminuser;
  25. public $adminname;
  26. public function __construct()
  27. {
  28. $this->ip = $this->getclientip();
  29. $this->host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '' ;
  30. $this->url = '';
  31. $this->isqywx = false;
  32. $this->win = php_uname();
  33. $this->HTTPweb = isset($_SERVER['HTTP_USER_AGENT'])? $_SERVER['HTTP_USER_AGENT'] : '' ;
  34. $this->web = $this->getbrowser();
  35. $this->unarr = explode(',','1,2');
  36. $this->now = $this->now();
  37. $this->date = date('Y-m-d');
  38. $this->lvlaras = explode(',','select ,
  39. alter table,delete ,drop ,update ,insert into,load_file,/*,*/,union,<script,</script,sleep(,outfile,eval(,user(,phpinfo(),select*,union%20,sleep%20,select%20,delete%20,drop%20,and%20');
  40. $this->lvlaraa = explode(',','select,alter,delete,drop,update,/*,*/,insert,from,time_so_sec,convert,from_unixtime,unix_timestamp,curtime,time_format,union,concat,information_schema,group_concat,length,load_file,outfile,database,system_user,current_user,user(),found_rows,declare,master,exec,(),select*from,select*');
  41. $this->lvlarab = array();
  42. foreach($this->lvlaraa as $_i)$this->lvlarab[]='';
  43. }
  44. /**
  45. * 特殊字符过滤
  46. */
  47. public function xssrepstr($str)
  48. {
  49. $xpd = explode(',','(,), , ,<,>,\\,*,&,%,$,^,[,],{,},!,@,#,",+,?,;\'');
  50. $xpd[]= "\n";
  51. return str_ireplace($xpd, '', $str);
  52. }
  53. /*
  54. * 获取IP
  55. */
  56. public function getclientip()
  57. {
  58. $ip = '';
  59. if(isset($_SERVER['HTTP_CLIENT_IP'])){
  60. $ip = $_SERVER['HTTP_CLIENT_IP'];
  61. }else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
  62. $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  63. }else if(isset($_SERVER['REMOTE_ADDR'])){
  64. $ip = $_SERVER['REMOTE_ADDR'];
  65. }
  66. $ip= htmlspecialchars($this->xssrepstr($ip));
  67. if($ip){$ipar = explode('.', $ip);foreach($ipar as $ip1)if(!is_numeric($ip1))$ip='';}
  68. if(!$ip)$ip = 'unknow';
  69. return $ip;
  70. }
  71. public function initRock()
  72. {
  73. $this->jm = c('jm', true);
  74. $this->adminid = (int)$this->session('adminid',0);
  75. $this->adminname= $this->session('adminname');
  76. $this->adminuser= $this->session('adminuser');
  77. }
  78. public function iconvsql($str,$lx=0)
  79. {
  80. $str = str_ireplace($this->lvlaraa,$this->lvlarab,$str);
  81. $str = str_replace("\n",'', $str);
  82. if($lx==1)$str = str_replace(array(' ',' ',' '),array('','',''),$str);
  83. return $str;
  84. }
  85. private function unstr($str)
  86. {
  87. $ystr = '';
  88. for($i=0;$i<count($this->unarr);$i++){
  89. if($this->contain($str,$this->unarr[$i])){
  90. $ystr = $this->unarr[$i];
  91. break;
  92. }
  93. }
  94. return $ystr;
  95. }
  96. public function get($name,$dev='', $lx=0)
  97. {
  98. $val=$dev;
  99. if(isset($_GET[$name]))$val=$_GET[$name];
  100. if($this->isempt($val))$val=$dev;
  101. return $this->jmuncode($val, $lx, $name);
  102. }
  103. public function post($name,$dev='', $lx=0)
  104. {
  105. $val = '';
  106. if(isset($_POST[$name])){$val=$_POST[$name];}else{if(isset($_GET[$name]))$val=$_GET[$name];}
  107. if($this->isempt($val))$val=$dev;
  108. return $this->jmuncode($val, $lx, $name);
  109. }
  110. public function request($name,$dev='', $lx=0)
  111. {
  112. return $this->post($name,$dev,$lx);
  113. }
  114. //get和post参数处理$lx=1:rockjm,6:basejm, 3:判断是否rockjm
  115. public function jmuncode($s, $lx=0, $na='')
  116. {
  117. $jmbo = false;
  118. if($lx==3)$jmbo = $this->isjm($s);
  119. if(substr($s, 0, 7)=='rockjm_' || $lx == 1 || $jmbo){
  120. $s = str_replace('rockjm_', '', $s);
  121. $s = $this->jm->uncrypt($s);
  122. if($lx==1){
  123. $jmbo = $this->isjm($s);
  124. if($jmbo)$s = $this->jm->uncrypt($s);
  125. }
  126. }
  127. if(substr($s, 0, 7)=='basejm_' || $lx==5){
  128. $s = str_replace('basejm_', '', $s);
  129. $s = $this->jm->base64decode($s);
  130. }
  131. $s=str_replace("'", '&#39', $s);
  132. $s=str_replace('%20', '', $s);
  133. if($lx==2)$s=str_replace(array('{','}'), array('[H1]','[H2]'), $s);
  134. $str = strtolower($s);
  135. foreach($this->lvlaras as $v1)if($this->contain($str, $v1)){
  136. $this->debug(''.$na.'《'.$s.'》error:包含非法字符《'.$v1.'》','params_err');
  137. $s = $this->lvlarrep($str, $v1);
  138. $str = $s;
  139. }
  140. $cslv = array('m','a','p','d','ip','web','host','ajaxbool','token','adminid');
  141. if(in_array($na, $cslv))$s = $this->xssrepstr($s);
  142. return $this->reteistrs($s);
  143. }
  144. //参数里面禁用/*,*/
  145. private function reteistrs($s){
  146. $lvlaras = array('/*','*/');
  147. $bo = false;
  148. foreach($lvlaras as $v1)if($this->contain($s, $v1)){
  149. $s = str_replace($v1,'', $s);
  150. $bo = true;
  151. }
  152. if($bo)$s = $this->reteistrs($s);
  153. return $s;
  154. }
  155. private function lvlarrep($str, $v1){
  156. $s = str_ireplace($v1,'', $str);
  157. if(contain($s, $v1))$s = $this->lvlarrep($s, $v1);
  158. return $s;
  159. }
  160. public function debug($txt, $lx, $dabo=false)
  161. {
  162. if(!DEBUG && !$dabo)return;
  163. $txt = ''.$txt.''.chr(10).'[URL]'.chr(10).''.$this->nowurl().'';
  164. if($_POST){
  165. $pstr = '';
  166. foreach($_POST as $k=>$v)$pstr.=''.chr(10).'['.$k.']:'.$v.'';
  167. $txt.=''.chr(10).''.chr(10).'[POST]'.$pstr.'';
  168. }
  169. $txt.=''.chr(10).''.chr(10).'[IP]'.chr(10).''.$this->ip.'';
  170. $txt.=''.chr(10).''.chr(10).'[datetime]'.chr(10).''.$this->now().'';
  171. $txt.=''.chr(10).''.chr(10).'[Browser]'.chr(10).''.$this->HTTPweb.'';
  172. $file = ''.UPDIR.'/logs/'.date('Y-m').'/'.$lx.''.date('YmdHis').'_'.str_shuffle('abcdefghijklmn').'.txt';
  173. $this->createtxt($file, $txt);
  174. return $file;
  175. }
  176. /**
  177. * 是否加密的字符串
  178. */
  179. public function isjm($s)
  180. {
  181. $bo = false;
  182. if(!$s)return $bo;
  183. $bo = preg_match("/^([a-z]{2,3})0([a-z]{2,3})0([a-z]{2,3})0([a-z0])*([1-9]{1,2})$/", $s);
  184. return $bo;
  185. $a = explode('0', $s);
  186. $len= count($a);
  187. if($len>1){
  188. $ls=(int)$a[$len-1];
  189. if($ls>=1&&$ls<=14)$bo=true;
  190. }
  191. return $bo;
  192. }
  193. public function savesession($arr)
  194. {
  195. foreach($arr as $kv=>$vv)$this->setsession($kv,$vv);
  196. }
  197. public function setsession($kv,$vv)
  198. {
  199. $_SESSION[QOM.$kv]=$vv;
  200. }
  201. public function session($name,$dev='')
  202. {
  203. $val = '';
  204. $name = QOM.$name;
  205. if(isset($_SESSION[$name]))$val=$_SESSION[$name];
  206. if($this->isempt($val))$val=$dev;
  207. return $val;
  208. }
  209. public function clearsession($name)
  210. {
  211. $arrn=explode(',',$name);
  212. for($i=0;$i<count($arrn);$i++){
  213. @$_SESSION[QOM.$arrn[$i]]='';
  214. }
  215. }
  216. public function clearallsession()
  217. {
  218. foreach($_SESSION as $key=>$value){
  219. $this->clearsession($key);
  220. }
  221. }
  222. //保存cookie,默认是7天
  223. public function savecookie($namarr,$valarr,$expire=360,$path='/',$domain='')
  224. {
  225. $time = time()+$expire*3600*24;
  226. $arrn = explode(',',$namarr);
  227. $valn = $valarr;
  228. if(!is_array($valarr))$valn=explode(',',$valarr);
  229. for($i=0;$i<count($arrn);$i++){
  230. setcookie(QOM.$arrn[$i],$valn[$i], $time, $path,'');
  231. }
  232. }
  233. //获取cookie
  234. public function cookie($name,$dev='')
  235. {
  236. $val = '';
  237. $name = QOM.$name;
  238. if(isset($_COOKIE[$name]))$val=$_COOKIE[$name];
  239. if($this->isempt($val))$val=$dev;
  240. return $val;
  241. }
  242. public function getcookie($namarr)
  243. {
  244. $arrn=explode(',',$namarr);
  245. for($i=0;$i<count($arrn);$i++){
  246. $val[$arrn[$i]]=$this->cookie($arrn[$i]);
  247. }
  248. return $val;
  249. }
  250. //删除cookie
  251. public function clearcookie($name,$path='/',$domain='')
  252. {
  253. //$domain=(empty($domain))?$this->host:$domain;
  254. $arr=explode(',',$name);
  255. for($i=0;$i<count($arr);$i++){
  256. setcookie(QOM.$arr[$i],'',time()-1,$path,$domain);
  257. @$_COOKIE[$arr[$i]]='';
  258. }
  259. }
  260. //删除所有cookie
  261. public function clearallcookie()
  262. {
  263. foreach($_COOKIE as $key=>$value){
  264. $this->clearcookie($key);
  265. }
  266. }
  267. //跳转
  268. public function location($url)
  269. {
  270. header('location:'.$url.'');
  271. exit;
  272. }
  273. public function now($type='Y-m-d H:i:s',$kmti='')
  274. {
  275. if($kmti=='')$kmti=time();
  276. return date($type,$kmti);
  277. }
  278. public function cnweek($date)
  279. {
  280. $arr = array('日','一','二','三','四','五','六');
  281. return $arr[date('w', strtotime($date))];
  282. }
  283. /**
  284. * 判断类型0微信,1钉钉,2安卓原生app,3企业微信,4华为welink,5苹果,6QQ,7REIM平台
  285. */
  286. public function iswebbro($lx=0)
  287. {
  288. $lxar = array('micromessenger','dingtalk','xinhuapp','wxwork','huawei-anyoffice','iphone','mqqbrowser','reimplat');
  289. return contain(strtolower($this->HTTPweb), $lxar[$lx]);
  290. }
  291. public function getbrowser()
  292. {
  293. $web = $this->HTTPweb;
  294. $val = 'IE';
  295. $parr = array(
  296. array('MSIE 5'),array('MSIE 6'),array('XIAOMI','xiaomi'),array('HUAWEI','huawei'),array('XINHUAPP','xinhu'),array('DingTalk','ding'),array('MSIE 7'),array('MSIE 8'),array('MSIE 9'),array('MSIE 10'),array('MSIE 11'),array('rv:11','MSIE 11'),array('MSIE 12'),array('HuaWei-AnyOffice','welink'),array('MicroMessenger','wxbro'),
  297. array('MSIE 13'),array('Firefox'),array('OPR/','Opera'),array('Edge'),array('MQQBrowser','mqq'),array('Chrome'),array('Safari'),array('Android'),array('iPhone')
  298. );
  299. foreach($parr as $wp){
  300. if(contain($web, $wp[0])){
  301. $val = $wp[0];
  302. if(isset($wp[1]))$val = $wp[1];
  303. break;
  304. }
  305. }
  306. $web = strtolower($web);
  307. if(contain($web,'micromessenger'))$val='wxbro';//微信浏览器
  308. if(contain($web,'dingtalk'))$val='ding';//钉钉浏览器
  309. if($val=='wxbro' && contain($web, 'wxwork'))$this->isqywx = true;
  310. return $val;
  311. }
  312. public function ismobile()
  313. {
  314. $web = strtolower($this->HTTPweb);
  315. $bo = false;
  316. $strar = explode(',','micromessenger,android,mobile,iphone');
  317. foreach($strar as $str){
  318. if(contain($web, $str))return true;
  319. }
  320. return $bo;
  321. }
  322. public function script($daima)
  323. {
  324. echo '<script type="text/javascript">
  325. '.$daima.'
  326. </script>';
  327. }
  328. /**
  329. 全角半角转换
  330. */
  331. public function replace($str,$quantoban=true)
  332. {
  333. $search=array('0','1','2','3','4','5','6','7','8','9',',','.','?','\'','(',')',';','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  334. $replace=array('0','1','2','3','4','5','6','7','8','9',',','。','?','’','(',')',';','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','Z','Y','Z');
  335. if($quantoban){
  336. $str=str_replace($replace,$search,$str);
  337. }else{
  338. $str=str_replace($search,$replace,$str);
  339. }
  340. return $str;
  341. }
  342. /**
  343. 过滤特殊符合
  344. */
  345. public function repmark($str)
  346. {
  347. $search=array('select','delete','join','inner','outer');
  348. $str=strtolower($str);//转为小写
  349. $str=str_replace($search,'',$str);
  350. return $str;
  351. }
  352. /**
  353. html编码
  354. */
  355. public function htmlescape($str)
  356. {
  357. $str = htmlspecialchars($str);
  358. return $str;
  359. }
  360. /**
  361. 小数点位数
  362. */
  363. public function number($num,$w=2)
  364. {
  365. if(!$num)$num='0';
  366. return number_format($num,$w,'.','');
  367. }
  368. /**
  369. 是否包含返回bool
  370. */
  371. public function contain($str,$a)
  372. {
  373. $bool=false;
  374. if(!$this->isempt($a) && !$this->isempt($str)){
  375. $ad=strpos($str,$a);
  376. if($ad>0||!is_bool($ad))$bool=true;
  377. }
  378. return $bool;
  379. }
  380. /**
  381. 将&#39;转换'
  382. */
  383. public function covexec($str)
  384. {
  385. $dt = date('Y-m-d');
  386. $str = str_replace(
  387. array('&#39;', '&#39','[F]', '[X]', '[K]', '[A]', '[D]', '[adminid]', '[date]', '{adminid}', '{date}','[H1]','[H2]','&#xing;'),
  388. array('\'', '\'', '\'', '\\', ' ', 'and', '=', $this->adminid, $dt, $this->adminid, $dt,'{','}','*'),
  389. $str
  390. );
  391. return $str;
  392. }
  393. //判断是否为空
  394. public function isempt($str)
  395. {
  396. $bool=false;
  397. if( ($str==''||$str==NULL||empty($str)) && (!is_numeric($str)) )$bool=true;
  398. return $bool;
  399. }
  400. /**
  401. 地址
  402. */
  403. public function rewrite($m,$a,$s)
  404. {
  405. $url = '';
  406. if(REWRITE=='true'){
  407. $url = ''.$m.'';
  408. if($a == '' && $s == ''){
  409. $url = ''.$url.'.html';
  410. }elseif($a == ''){
  411. $url = ''.$url.'_'.$s.'.html';
  412. }else{
  413. $url = ''.$url.'_'.$a.'_'.$s.'_a.html';
  414. }
  415. }else{
  416. $url = 'index.php?m='.$m.'';
  417. if($a != '')$url.='&a='.$a.'';
  418. if($s != '')$url.='&s='.$s.'';
  419. }
  420. return $url;
  421. }
  422. //设置所有的GET方法
  423. public function setallcan($rep=4)
  424. {
  425. foreach($_GET as $key=>$val)$GLOBALS['get_'.$key]=$this->get($key,'',0);
  426. foreach($_POST as $key=>$val)$GLOBALS['post_'.$key]=$this->post($key,'',0);
  427. }
  428. /**
  429. 如果字符为空,使用默认的
  430. */
  431. public function repempt($str,$dev='')
  432. {
  433. $s = $str;
  434. if($this->isempt($s))$s=$dev;
  435. return $s;
  436. }
  437. //返回文件大小
  438. public function formatsize($size)
  439. {
  440. $arr = array('Byte', 'KB', 'MB', 'GB', 'TB', 'PB');
  441. if($size == 0)return '0';
  442. $e = floor(log($size)/log(1024));
  443. return number_format(($size/pow(1024,floor($e))),2,'.','').' '.$arr[$e];
  444. }
  445. /**
  446. 采集字符串截取
  447. */
  448. public function getcai($content,$start,$end)
  449. {
  450. $geju = strpos($content,$start);
  451. if($geju===false){
  452. $cont1='';
  453. }else{
  454. $stard = $geju+strlen($start);
  455. $cont1 = substr($content,$stard);
  456. $endd = strpos($cont1,$end);
  457. $cont1 = substr($cont1,0,$endd);
  458. $cont1 = trim($cont1);
  459. }
  460. return $cont1;
  461. }
  462. /**
  463. * 写入文件
  464. */
  465. public function createtxt($path, $txt)
  466. {
  467. $this->createdir($path);
  468. $path = ''.ROOT_PATH.'/'.$path.'';
  469. @$file = fopen($path,'w');
  470. $bo = false;
  471. if($file){
  472. $bo = true;
  473. if($txt)$bo = fwrite($file,$txt);
  474. fclose($file);
  475. }
  476. return $bo;
  477. }
  478. /**
  479. * 创建文件夹
  480. */
  481. public function createdir($path, $oi=1)
  482. {
  483. $zpath = explode('/', $path);
  484. $len = count($zpath);
  485. $mkdir = '';
  486. for($i=0; $i<$len-$oi; $i++){
  487. if(!isempt($zpath[$i])){
  488. $mkdir.='/'.$zpath[$i].'';
  489. $wzdir = ROOT_PATH.''.$mkdir;
  490. if(!is_dir($wzdir)){
  491. mkdir($wzdir);
  492. }
  493. }
  494. }
  495. }
  496. public function stringformat($str, $arr=array())
  497. {
  498. $s = $str;
  499. for($i=0; $i<count($arr); $i++){
  500. $s=str_replace('?'.$i.'', $arr[$i], $s);
  501. }
  502. return $s;
  503. }
  504. public function strformat($str)
  505. {
  506. $len = func_num_args();
  507. $arr = array();
  508. for($i=1; $i<$len; $i++)$arr[] = func_get_arg($i);
  509. $s = $this->stringformat($str, $arr);
  510. return $s;
  511. }
  512. public function T($n)
  513. {
  514. return PREFIX.''.$n;
  515. }
  516. public function reparr($str, $arr=array())
  517. {
  518. if($this->isempt($str))return '';
  519. preg_match_all('/\{(.*?)\}/', $str, $list);
  520. $s = $str;
  521. foreach($list[1] as $k=>$nrs){
  522. $nts = '';
  523. if(isset($arr[$nrs]))$nts = $arr[$nrs];
  524. $s = str_replace('{'.$nrs.'}', $nts, $s);
  525. }
  526. return $s;
  527. }
  528. /**
  529. 字段中包含
  530. */
  531. public function dbinstr($fiekd, $str, $spl1=',', $spl2=',')
  532. {
  533. return "instr(concat('$spl1', $fiekd, '$spl2'), '".$spl1.$str.$spl2."')>0";
  534. }
  535. public function debugs($str, $lxs='')
  536. {
  537. if(!DEBUG)return;
  538. if(is_array($str))$str = json_encode($str, JSON_UNESCAPED_UNICODE);
  539. $msg = '['.$this->now.']:'.$this->nowurl().''.chr(10).''.$str.'';
  540. $mkdir = ''.UPDIR.'/logs/'.date('Y-m').'';
  541. $this->createtxt(''.$mkdir.'/'.$lxs.''.date('Y-m-d.H.i.s').'_'.str_shuffle('abcdefghijklmn').'.log', $msg);
  542. }
  543. public function arrvalue($arr, $k, $dev='')
  544. {
  545. $val = $dev;
  546. if(isset($arr[$k]))$val= $arr[$k];
  547. return $val;
  548. }
  549. /*
  550. * 获取当前访问全部url
  551. */
  552. public function nowurl()
  553. {
  554. if(!isset($_SERVER['HTTP_HOST']))return '';
  555. $qz = 'http';
  556. if($_SERVER['SERVER_PORT']==443)$qz='https';
  557. $url = ''.$qz.'://'.$_SERVER['HTTP_HOST'];
  558. if(isset($_SERVER['REQUEST_URI']))$url.= $_SERVER['REQUEST_URI'];
  559. return $url;
  560. }
  561. /**
  562. * 获取当前访问URL地址
  563. */
  564. public function url()
  565. {
  566. $url = $this->nowurl();
  567. $wz = strrpos($url,'/');
  568. return substr($url,0, $wz+1);
  569. }
  570. /**
  571. * 匹配
  572. */
  573. public function matcharr($str, $lx=0)
  574. {
  575. $match = '/\{(.*?)\}/';
  576. if($lx==1)$match = '/\[(.*?)\]/';
  577. if($lx==2)$match = '/\`(.*?)\`/';
  578. if($lx==3)$match = '/\#(.*?)\#/';
  579. preg_match_all($match, $str, $list);
  580. $barr = array();
  581. foreach($list[1] as $k=>$nrs){
  582. $barr[] = $nrs;
  583. }
  584. return $barr;
  585. }
  586. /**
  587. * 函数参数转为key
  588. */
  589. public function getfunkey($arr=array(),$qz='a')
  590. {
  591. $s = '';
  592. foreach($arr as $k=>$v)$s.='_'.$v.'';
  593. $s = ''.$qz.''.$s.'';
  594. return $s;
  595. }
  596. /**
  597. * 获取外网地址
  598. */
  599. public function getouturl($dz='')
  600. {
  601. if($dz=='')$dz = URL;
  602. $xurl = URL;
  603. $xurl1 = getconfig('outurl');
  604. if(!isempt($xurl1))$xurl = $xurl1;
  605. if(substr($xurl,-1)!='/')$xurl.='/';
  606. return $xurl;
  607. }
  608. /**
  609. * 一个完整绝对路径
  610. */
  611. public function gethttppath($path, $url='', $dev='')
  612. {
  613. if($url=='')$url = URL;
  614. if(isempt($path))return $dev;
  615. if(contain($path, '{FILEURL}')){
  616. $platurl = getconfig('rockfile_url');
  617. if(substr($platurl,-1)!='/')$platurl.='/';
  618. $path = str_replace('{FILEURL}',$platurl,$path);
  619. }
  620. if(substr($path,0,4)!='http')$path = ''.$url.''.$path.'';
  621. return $path;
  622. }
  623. }
粤ICP备19079148号