国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Maison développement back-end tutoriel php Explication détaillée des exemples d'opérations de base de soumission et de filtrage de données PHP

Explication détaillée des exemples d'opérations de base de soumission et de filtrage de données PHP

Feb 24, 2017 am 09:20 AM

本文實(shí)例講述了PHP數(shù)據(jù)的提交與過濾基本操作。分享給大家供大家參考,具體如下:

1、php提交數(shù)據(jù)過濾的基本原則

1)提交變量進(jìn)數(shù)據(jù)庫時,我們必須使用addslashes()進(jìn)行過濾,像我們的注入問題,一個addslashes()也就搞定了。其實(shí)在涉及到變量取值時,intval()函數(shù)對字符串的過濾也是個不錯的選擇。

2)在php.ini中開啟magic_quotes_gpc和magic_quotes_runtime。magic_quotes_gpc可以把get,post,cookie里的引號變?yōu)樾备堋?br>
magic_quotes_runtime對于進(jìn)出數(shù)據(jù)庫的數(shù)據(jù)可以起到格式話的作用。其實(shí),早在以前注入很瘋狂時,這個參數(shù)就很流行了。

3)在使用系統(tǒng)函數(shù)時,必須使用escapeshellarg(),escapeshellcmd()參數(shù)去過濾,這樣你也就可以放心的使用系統(tǒng)函數(shù)。

4)對于跨站,strip_tags(),htmlspecialchars()兩個參數(shù)都不錯,對于用戶提交的的帶有html和php的標(biāo)記都將進(jìn)行轉(zhuǎn)換。比如尖括號"<"就將轉(zhuǎn)化為 "<"這樣無害的字符。

$new = htmlspecialchars("<a href=&#39;test&#39;>Test</a>", ENT_QUOTES);
strip_tags($text,);



5)對于相關(guān)函數(shù)的過濾,就像先前的include(),unlink,fopen()等等,只要你把你所要執(zhí)行操作的變量指定好或者對相關(guān)字符過濾嚴(yán)密,我想

這樣也就無懈可擊了。

2、PHP簡單的數(shù)據(jù)過濾

1)入庫: trim($str),addslashes($str)

2)出庫: stripslashes($str)

3)顯示: htmlspecialchars(nl2br($str))

<?php
/**
 * global.func.php 公共函數(shù)庫
 */
/**
 * 返回經(jīng)addslashes處理過的字符串或數(shù)組
 * @param $string 需要處理的字符串或數(shù)組
 * @return mixed
 */
function new_addslashes($string){
 if(!is_array($string)) return addslashes($string);
 foreach($string as $key => $val) $string[$key] = new_addslashes($val);
 return $string;
}
/**
 * 返回經(jīng)stripslashes處理過的字符串或數(shù)組
 * @param $string 需要處理的字符串或數(shù)組
 * @return mixed
 */
function new_stripslashes($string) {
 if(!is_array($string)) return stripslashes($string);
 foreach($string as $key => $val) $string[$key] = new_stripslashes($val);
 return $string;
}
/**
 * 返回經(jīng)htmlspecialchars處理過的字符串或數(shù)組
 * @param $obj 需要處理的字符串或數(shù)組
 * @return mixed
 */
function new_html_special_chars($string) {
 $encoding = &#39;utf-8&#39;;
 if(strtolower(CHARSET)==&#39;gbk&#39;) $encoding = &#39;ISO-8859-15&#39;;
 if(!is_array($string)) return htmlspecialchars($string,ENT_QUOTES,$encoding);
 foreach($string as $key => $val) $string[$key] = new_html_special_chars($val);
 return $string;
}
function new_html_entity_decode($string) {
 $encoding = &#39;utf-8&#39;;
 if(strtolower(CHARSET)==&#39;gbk&#39;) $encoding = &#39;ISO-8859-15&#39;;
 return html_entity_decode($string,ENT_QUOTES,$encoding);
}
function new_htmlentities($string) {
 $encoding = &#39;utf-8&#39;;
 if(strtolower(CHARSET)==&#39;gbk&#39;) $encoding = &#39;ISO-8859-15&#39;;
 return htmlentities($string,ENT_QUOTES,$encoding);
}
/**
 * 安全過濾函數(shù)
 *
 * @param $string
 * @return string
 */
function safe_replace($string) {
 $string = str_replace(&#39;%20&#39;,&#39;&#39;,$string);
 $string = str_replace(&#39;%27&#39;,&#39;&#39;,$string);
 $string = str_replace(&#39;%2527&#39;,&#39;&#39;,$string);
 $string = str_replace(&#39;*&#39;,&#39;&#39;,$string);
 $string = str_replace(&#39;"&#39;,&#39;"&#39;,$string);
 $string = str_replace("&#39;",&#39;&#39;,$string);
 $string = str_replace(&#39;"&#39;,&#39;&#39;,$string);
 $string = str_replace(&#39;;&#39;,&#39;&#39;,$string);
 $string = str_replace(&#39;<&#39;,&#39;<&#39;,$string);
 $string = str_replace(&#39;>&#39;,&#39;>&#39;,$string);
 $string = str_replace("{",&#39;&#39;,$string);
 $string = str_replace(&#39;}&#39;,&#39;&#39;,$string);
 $string = str_replace(&#39;\\&#39;,&#39;&#39;,$string);
 return $string;
}
/**
 * xss過濾函數(shù)
 *
 * @param $string
 * @return string
 */
function remove_xss($string) {
 $string = preg_replace(&#39;/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S&#39;, &#39;&#39;, $string);
 $parm1 = Array(
 &#39;javascript&#39;, 
 &#39;vbscript&#39;,
  &#39;expression&#39;,
  &#39;applet&#39;,
   &#39;meta&#39;, 
   &#39;xml&#39;,
    &#39;blink&#39;, 
    &#39;link&#39;, 
    &#39;script&#39;, 
    &#39;embed&#39;, 
    &#39;object&#39;, 
    &#39;iframe&#39;, 
    &#39;frame&#39;, 
    &#39;frameset&#39;, 
    &#39;ilayer&#39;, 
    &#39;layer&#39;, 
    &#39;bgsound&#39;, 
    &#39;title&#39;, 
    &#39;base&#39;);
 $parm2 = Array(
 &#39;onabort&#39;, 
 &#39;onactivate&#39;, 
 &#39;onafterprint&#39;,
  &#39;onafterupdate&#39;,
   &#39;onbeforeactivate&#39;,
    &#39;onbeforecopy&#39;, 
    &#39;onbeforecut&#39;, 
    &#39;onbeforedeactivate&#39;, 
    &#39;onbeforeeditfocus&#39;, 
    &#39;onbeforepaste&#39;, 
    &#39;onbeforeprint&#39;, 
    &#39;onbeforeunload&#39;, 
    &#39;onbeforeupdate&#39;, 
    &#39;onblur&#39;, 
    &#39;onbounce&#39;, 
    &#39;oncellchange&#39;, 
    &#39;onchange&#39;, 
    &#39;onclick&#39;, 
    &#39;oncontextmenu&#39;, 
    &#39;oncontrolselect&#39;, 
    &#39;oncopy&#39;, 
    &#39;oncut&#39;, 
    &#39;ondataavailable&#39;, 
    &#39;ondatasetchanged&#39;, 
    &#39;ondatasetcomplete&#39;, 
    &#39;ondblclick&#39;, 
    &#39;ondeactivate&#39;, 
    &#39;ondrag&#39;, 
    &#39;ondragend&#39;, 
    &#39;ondragenter&#39;, 
    &#39;ondragleave&#39;, 
    &#39;ondragover&#39;, 
    &#39;ondragstart&#39;, 
    &#39;ondrop&#39;, 
    &#39;onerror&#39;, 
    &#39;onerrorupdate&#39;, 
    &#39;onfilterchange&#39;, 
    &#39;onfinish&#39;, 
    &#39;onfocus&#39;, 
    &#39;onfocusin&#39;, 
    &#39;onfocusout&#39;, 
    &#39;onhelp&#39;, 
    &#39;onkeydown&#39;, 
    &#39;onkeypress&#39;, 
    &#39;onkeyup&#39;, 
    &#39;onlayoutcomplete&#39;, 
    &#39;onload&#39;, 
    &#39;onlosecapture&#39;, 
    &#39;onmousedown&#39;, 
    &#39;onmouseenter&#39;, 
    &#39;onmouseleave&#39;, 
    &#39;onmousemove&#39;, 
    &#39;onmouseout&#39;, 
    &#39;onmouseover&#39;, 
    &#39;onmouseup&#39;, 
    &#39;onmousewheel&#39;, 
    &#39;onmove&#39;, 
    &#39;onmoveend&#39;, 
    &#39;onmovestart&#39;, 
    &#39;onpaste&#39;, 
    &#39;onpropertychange&#39;, 
    &#39;onreadystatechange&#39;, 
    &#39;onreset&#39;, 
    &#39;onresize&#39;, 
    &#39;onresizeend&#39;, 
    &#39;onresizestart&#39;, 
    &#39;onrowenter&#39;, 
    &#39;onrowexit&#39;, 
    &#39;onrowsdelete&#39;, 
    &#39;onrowsinserted&#39;, 
    &#39;onscroll&#39;, 
    &#39;onselect&#39;, 
    &#39;onselectionchange&#39;, 
    &#39;onselectstart&#39;, 
    &#39;onstart&#39;, 
    &#39;onstop&#39;, 
    &#39;onsubmit&#39;, 
    &#39;onunload&#39;);
 $parm = array_merge($parm1, $parm2);
 for ($i = 0; $i < sizeof($parm); $i++) {
  $pattern = &#39;/&#39;;
  for ($j = 0; $j < strlen($parm[$i]); $j++) {
   if ($j > 0) {
    $pattern .= &#39;(&#39;;
    $pattern .= &#39;([x|X]0([9][a][b]);?)?&#39;;
    $pattern .= &#39;|(([9][10][13]);?)?&#39;;
    $pattern .= &#39;)?&#39;;
   }
   $pattern .= $parm[$i][$j];
  }
  $pattern .= &#39;/i&#39;;
  $string = preg_replace($pattern, &#39; &#39;, $string);
 }
 return $string;
}
/**
 * 過濾ASCII碼從0-28的控制字符
 * @return String
 */
function trim_unsafe_control_chars($str) {
 $rule = &#39;/[&#39; . chr ( 1 ) . &#39;-&#39; . chr ( 8 ) . chr ( 11 ) . &#39;-&#39; . chr ( 12 ) . chr ( 14 ) . &#39;-&#39; . chr ( 31 ) . &#39;]*/&#39;;
 return str_replace ( chr ( 0 ), &#39;&#39;, preg_replace ( $rule, &#39;&#39;, $str ) );
}
/**
 * 格式化文本域內(nèi)容
 *
 * @param $string 文本域內(nèi)容
 * @return string
 */
function trim_textarea($string) {
 $string = nl2br ( str_replace ( &#39; &#39;, &#39; &#39;, $string ) );
 return $string;
}
/**
 * 將文本格式成適合js輸出的字符串
 * @param string $string 需要處理的字符串
 * @param intval $isjs 是否執(zhí)行字符串格式化,默認(rèn)為執(zhí)行
 * @return string 處理后的字符串
 */
function format_js($string, $isjs = 1) {
 $string = addslashes(str_replace(array("\r", "\n", "\t"), array(&#39;&#39;, &#39;&#39;, &#39;&#39;), $string));
 return $isjs ? &#39;document.write("&#39;.$string.&#39;");&#39; : $string;
}
/**
 * 轉(zhuǎn)義 javascript 代碼標(biāo)記
 *
 * @param $str
 * @return mixed
 */
 function trim_script($str) {
 if(is_array($str)){
  foreach ($str as $key => $val){
   $str[$key] = trim_script($val);
  }
  }else{
   $str = preg_replace ( &#39;/\<([\/]?)script([^\>]*?)\>/si&#39;, &#39;<\\1script\\2>&#39;, $str );
  $str = preg_replace ( &#39;/\<([\/]?)iframe([^\>]*?)\>/si&#39;, &#39;<\\1iframe\\2>&#39;, $str );
  $str = preg_replace ( &#39;/\<([\/]?)frame([^\>]*?)\>/si&#39;, &#39;<\\1frame\\2>&#39;, $str );
  $str = str_replace ( &#39;javascript:&#39;, &#39;javascript:&#39;, $str );
  }
 return $str;
}
/**
 * 獲取當(dāng)前頁面完整URL地址
 */
function get_url() {
 $sys_protocal = isset($_SERVER[&#39;SERVER_PORT&#39;]) && $_SERVER[&#39;SERVER_PORT&#39;] == &#39;443&#39; ? &#39;https://&#39; : &#39;http://&#39;;
 $php_self = $_SERVER[&#39;PHP_SELF&#39;] ? safe_replace($_SERVER[&#39;PHP_SELF&#39;]) : safe_replace($_SERVER[&#39;SCRIPT_NAME&#39;]);
 $path_info = isset($_SERVER[&#39;PATH_INFO&#39;]) ? safe_replace($_SERVER[&#39;PATH_INFO&#39;]) : &#39;&#39;;
 $relate_url = isset($_SERVER[&#39;REQUEST_URI&#39;]) ? safe_replace($_SERVER[&#39;REQUEST_URI&#39;]) : 
 $php_self.(isset($_SERVER[&#39;QUERY_STRING&#39;]) ? &#39;?&#39;.safe_replace($_SERVER[&#39;QUERY_STRING&#39;]) : $path_info);
 return $sys_protocal.(isset($_SERVER[&#39;HTTP_HOST&#39;]) ? $_SERVER[&#39;HTTP_HOST&#39;] : &#39;&#39;).$relate_url;
}
/**
 * 字符截取 支持UTF8/GBK
 * @param $string
 * @param $length
 * @param $dot
 */
function str_cut($string, $length, $dot = &#39;...&#39;) {
 $strlen = strlen($string);
 if($strlen <= $length) return $string;
 $string = str_replace(array(&#39; &#39;,&#39; &#39;, &#39;&&#39;, &#39;"&#39;, &#39;&#39;&#39;, &#39;“&#39;, &#39;”&#39;, &#39;—&#39;, &#39;<&#39;, &#39;>&#39;, &#39;·&#39;, &#39;…&#39;), 
 array(&#39;∵&#39;,&#39; &#39;, &#39;&&#39;, &#39;"&#39;, "&#39;", &#39;“&#39;, &#39;”&#39;, &#39;―&#39;, &#39;<&#39;, &#39;>&#39;, &#39;?&#39;, &#39;…&#39;), $string);
 $strcut = &#39;&#39;;
 if(strtolower(CHARSET) == &#39;utf-8&#39;) {
  $length = intval($length-strlen($dot)-$length/3);
  $n = $tn = $noc = 0;
  while($n < strlen($string)) {
   $t = ord($string[$n]);
   if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) {
    $tn = 1; $n++; $noc++;
   } elseif(194 <= $t && $t <= 223) {
    $tn = 2; $n += 2; $noc += 2;
   } elseif(224 <= $t && $t <= 239) {
    $tn = 3; $n += 3; $noc += 2;
   } elseif(240 <= $t && $t <= 247) {
    $tn = 4; $n += 4; $noc += 2;
   } elseif(248 <= $t && $t <= 251) {
    $tn = 5; $n += 5; $noc += 2;
   } elseif($t == 252 || $t == 253) {
    $tn = 6; $n += 6; $noc += 2;
   } else {
    $n++;
   }
   if($noc >= $length) {
    break;
   }
  }
  if($noc > $length) {
   $n -= $tn;
  }
  $strcut = substr($string, 0, $n);
  $strcut = str_replace(array(&#39;∵&#39;, &#39;&&#39;, &#39;"&#39;, "&#39;", &#39;“&#39;, &#39;”&#39;, &#39;―&#39;, &#39;<&#39;, &#39;>&#39;, &#39;?&#39;, &#39;…&#39;), 
  array(&#39; &#39;, &#39;&&#39;, &#39;"&#39;, &#39;&#39;&#39;, &#39;“&#39;, &#39;”&#39;, &#39;—&#39;, &#39;<&#39;, &#39;>&#39;, &#39;·&#39;, &#39;…&#39;), $strcut);
 } else {
  $dotlen = strlen($dot);
  $maxi = $length - $dotlen - 1;
  $current_str = &#39;&#39;;
  $search_arr = array(&#39;&&#39;,&#39; &#39;, &#39;"&#39;, "&#39;", &#39;“&#39;, &#39;”&#39;, &#39;―&#39;, &#39;<&#39;, &#39;>&#39;, &#39;?&#39;, &#39;…&#39;,&#39;∵&#39;);
  $replace_arr = array(&#39;&&#39;,&#39; &#39;, &#39;"&#39;, &#39;&#39;&#39;, &#39;“&#39;, &#39;”&#39;, &#39;—&#39;, &#39;<&#39;, &#39;>&#39;, &#39;·&#39;, &#39;…&#39;,&#39; &#39;);
  $search_flip = array_flip($search_arr);
  for ($i = 0; $i < $maxi; $i++) {
   $current_str = ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
   if (in_array($current_str, $search_arr)) {
    $key = $search_flip[$current_str];
    $current_str = str_replace($search_arr[$key], $replace_arr[$key], $current_str);
   }
   $strcut .= $current_str;
  }
 }
 return $strcut.$dot;
}
/**
 * 獲取請求ip
 *
 * @return ip地址
 */
function ip() {
 if(getenv(&#39;HTTP_CLIENT_IP&#39;) && strcasecmp(getenv(&#39;HTTP_CLIENT_IP&#39;), &#39;unknown&#39;)) {
  $ip = getenv(&#39;HTTP_CLIENT_IP&#39;);
 } elseif(getenv(&#39;HTTP_X_FORWARDED_FOR&#39;) && strcasecmp(getenv(&#39;HTTP_X_FORWARDED_FOR&#39;), &#39;unknown&#39;)) {
  $ip = getenv(&#39;HTTP_X_FORWARDED_FOR&#39;);
 } elseif(getenv(&#39;REMOTE_ADDR&#39;) && strcasecmp(getenv(&#39;REMOTE_ADDR&#39;), &#39;unknown&#39;)) {
  $ip = getenv(&#39;REMOTE_ADDR&#39;);
 } elseif(isset($_SERVER[&#39;REMOTE_ADDR&#39;]) && $_SERVER[&#39;REMOTE_ADDR&#39;] && 
 strcasecmp($_SERVER[&#39;REMOTE_ADDR&#39;], &#39;unknown&#39;)) {
  $ip = $_SERVER[&#39;REMOTE_ADDR&#39;];
 }
 return preg_match ( &#39;/[\d\.]{7,15}/&#39;, $ip, $matches ) ? $matches [0] : &#39;&#39;;
}
function get_cost_time() {
 $microtime = microtime ( TRUE );
 return $microtime - SYS_START_TIME;
}
/**
 * 程序執(zhí)行時間
 *
 * @return int 單位ms
 */
function execute_time() {
 $stime = explode ( &#39; &#39;, SYS_START_TIME );
 $etime = explode ( &#39; &#39;, microtime () );
 return number_format ( ($etime [1] + $etime [0] - $stime [1] - $stime [0]), 6 );
}
/**
* 將字符串轉(zhuǎn)換為數(shù)組
*
* @param string $data 字符串
* @return array 返回數(shù)組格式,如果,data為空,則返回空數(shù)組
*/
function string2array($data) {
 if($data == &#39;&#39;) return array();
 $data = stripslashes($data);
 @eval("\$array = $data;");
 return $array;
}
/**
* 將數(shù)組轉(zhuǎn)換為字符串
*
* @param array $data  數(shù)組
* @param bool $isformdata 如果為0,則不使用new_stripslashes處理,可選參數(shù),默認(rèn)為1
* @return string 返回字符串,如果,data為空,則返回空
*/
function array2string($data, $isformdata = 1) {
 if($data == &#39;&#39;) return &#39;&#39;;
 if($isformdata) $data = new_stripslashes($data);
 return addslashes(var_export($data, TRUE));
}
/**
* 轉(zhuǎn)換字節(jié)數(shù)為其他單位
*
*
* @param string $filesize 字節(jié)大小
* @return string 返回大小
*/
function sizecount($filesize) {
 if ($filesize >= 1073741824) {
  $filesize = round($filesize / 1073741824 * 100) / 100 .&#39; GB&#39;;
 } elseif ($filesize >= 1048576) {
  $filesize = round($filesize / 1048576 * 100) / 100 .&#39; MB&#39;;
 } elseif($filesize >= 1024) {
  $filesize = round($filesize / 1024 * 100) / 100 . &#39; KB&#39;;
 } else {
  $filesize = $filesize.&#39; Bytes&#39;;
 }
 return $filesize;
}
/**
* 字符串加密、解密函數(shù)
*
*
* @param string $txt  字符串
* @param string $operation ENCODE為加密,DECODE為解密,可選參數(shù),默認(rèn)為ENCODE,
* @param string $key  密鑰:數(shù)字、字母、下劃線
* @param string $expiry  過期時間
* @return string
*/
function sys_auth($string, $operation = &#39;ENCODE&#39;, $key = &#39;&#39;, $expiry = 0) {
 $key_length = 4;
 $key = md5($key != &#39;&#39; ? $key : app_base::load_config(&#39;system&#39;, &#39;auth_key&#39;));
 $fixedkey = md5($key);
 $egiskeys = md5(substr($fixedkey, 16, 16));
 $runtokey = $key_length ? ($operation == &#39;ENCODE&#39; ? substr(md5(microtime(true)), -$key_length) : substr($string, 0, $key_length)) : &#39;&#39;;
 $keys = md5(substr($runtokey, 0, 16) . substr($fixedkey, 0, 16) . substr($runtokey, 16) . substr($fixedkey, 16));
 $string = $operation == &#39;ENCODE&#39; ? sprintf(&#39;%010d&#39;, $expiry ? $expiry + time() : 0).substr(md5($string.$egiskeys), 0, 16) . 
 $string : base64_decode(substr($string, $key_length));
 $i = 0; $result = &#39;&#39;;
 $string_length = strlen($string);
 for ($i = 0; $i < $string_length; $i++){
  $result .= chr(ord($string{$i}) ^ ord($keys{$i % 32}));
 }
 if($operation == &#39;ENCODE&#39;) {
  return $runtokey . str_replace(&#39;=&#39;, &#39;&#39;, base64_encode($result));
 } else {
  if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$egiskeys), 0, 16)) {
   return substr($result, 26);
  } else {
   return &#39;&#39;;
  }
 }
}
/**
* 語言文件處理
*
* @param string  $language 標(biāo)示符
* @param array  $pars 轉(zhuǎn)義的數(shù)組,二維數(shù)組 ,&#39;key1&#39;=>&#39;value1&#39;,&#39;key2&#39;=>&#39;value2&#39;,
* @param string  $modules 多個模塊之間用半角逗號隔開,如:member,guestbook
* @return string  語言字符
*/
function L($language = &#39;no_language&#39;,$pars = array(), $modules = &#39;&#39;) {
 static $LANG = array();
 static $LANG_MODULES = array();
 static $lang = &#39;&#39;;
 if(defined(&#39;IN_ADMIN&#39;)) {
  $lang = SYS_STYLE ? SYS_STYLE : &#39;zh-cn&#39;;
 } else {
  $lang = app_base::load_config(&#39;system&#39;,&#39;lang&#39;);
 }
 if(!$LANG) {
  require_once CODE_PATH.&#39;languages&#39;.DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.&#39;system.lang.php&#39;;
  if(defined(&#39;IN_ADMIN&#39;)) require_once CODE_PATH.&#39;languages&#39;.DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.&#39;system_menu.lang.php&#39;;
  if(file_exists(CODE_PATH.&#39;languages&#39;.DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.ROUTE_M.&#39;.lang.php&#39;)) require_once CODE_PATH.&#39;languages&#39;.
  DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.ROUTE_M.&#39;.lang.php&#39;;
 }
 if(!empty($modules)) {
  $modules = explode(&#39;,&#39;,$modules);
  foreach($modules AS $m) {
   if(!isset($LANG_MODULES[$m])) require_once CODE_PATH.&#39;languages&#39;.DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.$m.&#39;.lang.php&#39;;
  }
 }
 if(!array_key_exists($language,$LANG)) {
  return $language;
 } else {
  $language = $LANG[$language];
  if($pars) {
   foreach($pars AS $_k=>$_v) {
    $language = str_replace(&#39;{&#39;.$_k.&#39;}&#39;,$_v,$language);
   }
  }
  return $language;
 }
}
/**
 * 模板調(diào)用
 *
 * @param $module
 * @param $template
 * @param $istag
 * @return unknown_type
 */
function template($module = &#39;content&#39;, $template = &#39;index&#39;, $style = &#39;&#39;) {
 if(strpos($module, &#39;plugin/&#39;)!== false) {
  $plugin = str_replace(&#39;plugin/&#39;, &#39;&#39;, $module);
  return p_template($plugin, $template,$style);
 }
 $module = str_replace(&#39;/&#39;, DIRECTORY_SEPARATOR, $module);
 if(!empty($style) && preg_match(&#39;/([a-z0-9\-_]+)/is&#39;,$style)) {
 } elseif (empty($style) && !defined(&#39;STYLE&#39;)) {
  if(defined(&#39;SITEID&#39;)) {
   $siteid = SITEID;
  } else {
   $siteid = param::get_cookie(&#39;siteid&#39;);
  }
  if (!$siteid) $siteid = 1;
  $sitelist = getcache(&#39;sitelist&#39;,&#39;commons&#39;);
  if(!empty($siteid)) {
   $style = $sitelist[$siteid][&#39;default_style&#39;];
  }
 } elseif (empty($style) && defined(&#39;STYLE&#39;)) {
  $style = STYLE;
 } else {
  $style = &#39;default&#39;;
 }
 if(!$style) $style = &#39;default&#39;;
 $template_cache = app_base::load_sys_class(&#39;template_cache&#39;);
 $compiledtplfile = ROOT_PATH.&#39;caches&#39;.DIRECTORY_SEPARATOR.&#39;caches_template&#39;.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.&#39;.php&#39;;
 if(file_exists(CODE_PATH.&#39;templates&#39;.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.&#39;.html&#39;)) {
  if(!file_exists($compiledtplfile) || (@filemtime(CODE_PATH.&#39;templates&#39;.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.
  $module.DIRECTORY_SEPARATOR.$template.&#39;.html&#39;) > @filemtime($compiledtplfile))) {
   $template_cache->template_compile($module, $template, $style);
  }
 } else {
  $compiledtplfile = ROOT_PATH.&#39;caches&#39;.DIRECTORY_SEPARATOR.&#39;caches_template&#39;.DIRECTORY_SEPARATOR.&#39;default&#39;.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.&#39;.php&#39;;
  if(!file_exists($compiledtplfile) || (file_exists(CODE_PATH.&#39;templates&#39;.DIRECTORY_SEPARATOR.&#39;default&#39;.DIRECTORY_SEPARATOR.$module.
  DIRECTORY_SEPARATOR.$template.&#39;.html&#39;) && filemtime(CODE_PATH.&#39;templates&#39;.DIRECTORY_SEPARATOR.&#39;default&#39;.DIRECTORY_SEPARATOR.$module.
  DIRECTORY_SEPARATOR.$template.&#39;.html&#39;) > filemtime($compiledtplfile))) {
   $template_cache->template_compile($module, $template, &#39;default&#39;);
  } elseif (!file_exists(CODE_PATH.&#39;templates&#39;.DIRECTORY_SEPARATOR.&#39;default&#39;.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.&#39;.html&#39;)) {
   showmessage(&#39;Template does not exist.&#39;.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$template.&#39;.html&#39;);
  }
 }
 return $compiledtplfile;
}
/**
 * 輸出自定義錯誤
 *
 * @param $errno 錯誤號
 * @param $errstr 錯誤描述
 * @param $errfile 報錯文件地址
 * @param $errline 錯誤行號
 * @return string 錯誤提示
 */
function my_error_handler($errno, $errstr, $errfile, $errline) {
 if($errno==8) return &#39;&#39;;
 $errfile = str_replace(ROOT_PATH,&#39;&#39;,$errfile);
 if(app_base::load_config(&#39;system&#39;,&#39;errorlog&#39;)) {
  error_log(&#39;<?php exit;?>&#39;.date(&#39;m-d H:i:s&#39;,SYS_TIME).&#39; | &#39;.$errno.&#39; | &#39;.str_pad($errstr,30).&#39; | &#39;.$errfile.&#39; | &#39;.$errline."\r\n", 3, CACHE_PATH.&#39;error_log.php&#39;);
 } else {
  $str = &#39;<p style="font-size:12px;text-align:left; border-bottom:1px solid #9cc9e0; border-right:1px solid #9cc9e0;padding:1px 4px;color:#000000;
  font-family:Arial, Helvetica,sans-serif;"><span>errorno:&#39; . $errno . &#39;,str:&#39; . $errstr . &#39;,file:<font color="blue">&#39; .
   $errfile . &#39;</font>,line&#39; . $errline .&#39;<br />Need Help?</span></p>&#39;;
  echo $str;
 }
}
/**
 * 提示信息頁面跳轉(zhuǎn),跳轉(zhuǎn)地址如果傳入數(shù)組,頁面會提示多個地址供用戶選擇,默認(rèn)跳轉(zhuǎn)地址為數(shù)組的第一個值,時間為5秒。
 * showmessage(&#39;登錄成功&#39;, array(&#39;默認(rèn)跳轉(zhuǎn)地址&#39;=>&#39;http://www.baidu.com&#39;));
 * @param string $msg 提示信息
 * @param mixed(string/array) $url_forward 跳轉(zhuǎn)地址
 * @param int $ms 跳轉(zhuǎn)等待時間
 */
function showmessage($msg, $url_forward = &#39;goback&#39;, $ms = 1250, $dialog = &#39;&#39;, $returnjs = &#39;&#39;) {
 if(defined(&#39;IN_ADMIN&#39;)) {
  include(admin::admin_tpl(&#39;showmessage&#39;, &#39;admin&#39;));
 } else {
  include(template(&#39;content&#39;, &#39;message&#39;));
 }
 exit;
}
/**
 * 查詢字符是否存在于某字符串
 *
 * @param $haystack 字符串
 * @param $needle 要查找的字符
 * @return bool
 */
function str_exists($haystack, $needle)
{
 return !(strpos($haystack, $needle) === FALSE);
}
/**
 * 取得文件擴(kuò)展
 *
 * @param $filename 文件名
 * @return 擴(kuò)展名
 */
function fileext($filename) {
 return strtolower(trim(substr(strrchr($filename, &#39;.&#39;), 1, 10)));
}
/**
 * 加載模板標(biāo)簽緩存
 * @param string $name 緩存名
 * @param integer $times 緩存時間
 */
function tpl_cache($name,$times = 0) {
 $filepath = &#39;tpl_data&#39;;
 $info = getcacheinfo($name, $filepath);
 if (SYS_TIME - $info[&#39;filemtime&#39;] >= $times) {
  return false;
 } else {
  return getcache($name,$filepath);
 }
}
/**
 * 寫入緩存,默認(rèn)為文件緩存,不加載緩存配置。
 * @param $name 緩存名稱
 * @param $data 緩存數(shù)據(jù)
 * @param $filepath 數(shù)據(jù)路徑(模塊名稱) caches/cache_$filepath/
 * @param $type 緩存類型[file,memcache,apc]
 * @param $config 配置名稱
 * @param $timeout 過期時間
 */
function setcache($name, $data, $filepath=&#39;&#39;, $type=&#39;file&#39;, $c AND &#39;, $in_column = false) {
 if($in_column && is_array($data)) {
  $ids = &#39;\&#39;&#39;.implode(&#39;\&#39;,\&#39;&#39;, $data).&#39;\&#39;&#39;;
  $sql = "$in_column IN ($ids)";
  return $sql;
 } else {
  if ($front == &#39;&#39;) {
   $front = &#39; AND &#39;;
  }
  if(is_array($data) && count($data) > 0) {
   $sql = &#39;&#39;;
   foreach ($data as $key => $val) {
    $sql .= $sql ? " $front $key = &#39;$val&#39; " : " $key = &#39;$val&#39; ";
   }
   return $sql;
  } else {
   return $data;
  }
 }
}
/**
 * 分頁函數(shù)
 *
 * @param $num 信息總數(shù)
 * @param $curr_page 當(dāng)前分頁
 * @param $perpage 每頁顯示數(shù)
 * @param $urlrule URL規(guī)則
 * @param $array 需要傳遞的數(shù)組,用于增加額外的方法
 * @return 分頁
 */
function pages($num, $curr_page, $perpage = 20, $urlrule = &#39;&#39;, $array = array(),$setpages = 10) {
 if(defined(&#39;URLRULE&#39;) && $urlrule == &#39;&#39;) {
  $urlrule = URLRULE;
  $array = $GLOBALS[&#39;URL_ARRAY&#39;];
 } elseif($urlrule == &#39;&#39;) {
  $urlrule = url_par(&#39;page={$page}&#39;);
 }
 $multipage = &#39;&#39;;
 if($num > $perpage) {
  $page = $setpages+1;
  $offset = ceil($setpages/2-1);
  $pages = ceil($num / $perpage);
  if (defined(&#39;IN_ADMIN&#39;) && !defined(&#39;PAGES&#39;)) define(&#39;PAGES&#39;, $pages);
  $from = $curr_page - $offset;
  $to = $curr_page + $offset;
  $more = 0;
  if($page >= $pages) {
   $from = 2;
   $to = $pages-1;
  } else {
   if($from <= 1) {
    $to = $page-1;
    $from = 2;
   } elseif($to >= $pages) {
    $from = $pages-($page-2);
    $to = $pages-1;
   }
   $more = 1;
  }
  //$multipage .= &#39;<a class="a1">&#39;.$num.L(&#39;page_item&#39;).&#39;</a>&#39;;
  if($curr_page>0) {
   $multipage .= &#39; <a href="&#39;.pageurl($urlrule, $curr_page-1, $array).&#39;" class="a1">&#39;.L(&#39;previous&#39;).&#39;</a>&#39;;
   if($curr_page==1) {
    $multipage .= &#39; <span>1</span>&#39;;
   } elseif($curr_page>6 && $more) {
    $multipage .= &#39; <a href="&#39;.pageurl($urlrule, 1, $array).&#39;">1</a>..&#39;;
   } else {
    $multipage .= &#39; <a href="&#39;.pageurl($urlrule, 1, $array).&#39;">1</a>&#39;;
   }
  }
  for($i = $from; $i <= $to; $i++) {
   if($i != $curr_page) {
    $multipage .= &#39; <a href="&#39;.pageurl($urlrule, $i, $array).&#39;">&#39;.$i.&#39;</a>&#39;;
   } else {
    $multipage .= &#39; <span>&#39;.$i.&#39;</span>&#39;;
   }
  }
  if($curr_page<$pages) {
   if($curr_page<$pages-5 && $more) {
    $multipage .= &#39; ..<a href="&#39;.pageurl($urlrule, $pages, $array).&#39;">&#39;.$pages.&#39;</a> <a href="&#39;.pageurl($urlrule, $curr_page+1, $array).&#39;" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
   } else {
    $multipage .= &#39; <a href="&#39;.pageurl($urlrule, $pages, $array).&#39;">&#39;.$pages.&#39;</a> <a href="&#39;.pageurl($urlrule, $curr_page+1, $array).&#39;" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
   }
  } elseif($curr_page==$pages) {
   $multipage .= &#39; <span>&#39;.$pages.&#39;</span> <a href="&#39;.pageurl($urlrule, $curr_page, $array).&#39;" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
  } else {
   $multipage .= &#39; <a href="&#39;.pageurl($urlrule, $pages, $array).&#39;">&#39;.$pages.&#39;</a> <a href="&#39;.pageurl($urlrule, $curr_page+1, $array).&#39;" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
  }
 }
 return $multipage;
}
function pages1($num, $curr_page, $perpage = 20, $urlrule = &#39;&#39;, $array = array(),$setpages = 10) {
 if(defined(&#39;URLRULE&#39;) && $urlrule == &#39;&#39;) {
  $urlrule = URLRULE;
  $array = $GLOBALS[&#39;URL_ARRAY&#39;];
 } elseif($urlrule == &#39;&#39;) {
  $urlrule = url_par(&#39;page={$page}&#39;);
 }
 $multipage = &#39;&#39;;
 if($num > $perpage) {
  $page = $setpages+1;
  $offset = ceil($setpages/2-1);
  $pages = ceil($num / $perpage);
  if (defined(&#39;IN_ADMIN&#39;) && !defined(&#39;PAGES&#39;)) define(&#39;PAGES&#39;, $pages);
  $from = $curr_page - $offset;
  $to = $curr_page + $offset;
  $more = 0;
  if($page >= $pages) {
   $from = 2;
   $to = $pages-1;
  } else {
   if($from <= 1) {
    $to = $page-1;
    $from = 2;
   } elseif($to >= $pages) {
    $from = $pages-($page-2);
    $to = $pages-1;
   }
   $more = 1;
  }
  //$multipage .= &#39;<a class="a1">&#39;.$num.L(&#39;page_item&#39;).&#39;</a>&#39;;
  if($curr_page>0) {
   $multipage .= &#39; <a href="###" class="a1">&#39;.L(&#39;previous&#39;).&#39;</a>&#39;;
   if($curr_page==1) {
    $multipage .= &#39; <span>1</span>&#39;;
   } elseif($curr_page>6 && $more) {
    $multipage .= &#39; <a href="###" /a>..&#39;;
   } else {
    $multipage .= &#39; <a href="###" /a>&#39;;
   }
  }
  for($i = $from; $i <= $to; $i++) {
   if($i != $curr_page) {
    $multipage .= &#39; <a href="###" /a>&#39;;
   } else {
    $multipage .= &#39; <span>&#39;.$i.&#39;</span>&#39;;
   }
  }
  if($curr_page<$pages) {
   if($curr_page<$pages-5 && $more) {
    $multipage .= &#39; ..<a href="###" /a> <a href="###" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
   } else {
    $multipage .= &#39; <a href="###" /a> <a href="###" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
   }
  } elseif($curr_page==$pages) {
   $multipage .= &#39; <span>&#39;.$pages.&#39;</span> <a href="###" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
  } else {
   $multipage .= &#39; <a href="###" /a> <a href="###" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
  }
 }
 return $multipage;
}
function pages2($num, $curr_page, $pages, $urlrule = &#39;&#39;, $array = array(),$setpages = 10) {
 if(defined(&#39;URLRULE&#39;) && $urlrule == &#39;&#39;) {
  $urlrule = URLRULE;
  $array = $GLOBALS[&#39;URL_ARRAY&#39;];
 } elseif($urlrule == &#39;&#39;) {
  $urlrule = url_par(&#39;page={$page}&#39;);
 }
 $multipage = &#39;&#39;;
 if($pages > 1) {
  $page = $setpages+1;
  $offset = ceil($setpages/2-1);
  if (defined(&#39;IN_ADMIN&#39;) && !defined(&#39;PAGES&#39;)) define(&#39;PAGES&#39;, $pages);
  $from = $curr_page - $offset;
  $to = $curr_page + $offset;
  $more = 0;
  if($page >= $pages) {
   $from = 2;
   $to = $pages-1;
  } else {
   if($from <= 1) {
    $to = $page-1;
    $from = 2;
   } elseif($to >= $pages) {
    $from = $pages-($page-2);
    $to = $pages-1;
   }
   $more = 1;
  }
  //$multipage .= &#39;<a class="a1">&#39;.$num.L(&#39;page_item&#39;).&#39;</a>&#39;;
  if($curr_page>0) {
   $multipage .= &#39; <a href="###" class="a1">&#39;.L(&#39;previous&#39;).&#39;</a>&#39;;
   if($curr_page==1) {
    $multipage .= &#39; <span>1</span>&#39;;
   } elseif($curr_page>6 && $more) {
    $multipage .= &#39; <a href="###" /a>..&#39;;
   } else {
    $multipage .= &#39; <a href="###" /a>&#39;;
   }
  }
  for($i = $from; $i <= $to; $i++) {
   if($i != $curr_page) {
    $multipage .= &#39; <a href="###" /a>&#39;;
   } else {
    $multipage .= &#39; <span>&#39;.$i.&#39;</span>&#39;;
   }
  }
  if($curr_page<$pages) {
   if($curr_page<$pages-5 && $more) {
    $multipage .= &#39; ..<a href="###" /a> <a href="###" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
   } else {
    $multipage .= &#39; <a href="###" /a> <a href="###" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
   }
  } elseif($curr_page==$pages) {
   $multipage .= &#39; <span>&#39;.$pages.&#39;</span> <a href="###" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
  } else {
   $multipage .= &#39; <a href="###" /a> <a href="###" class="a1">&#39;.L(&#39;next&#39;).&#39;</a>&#39;;
  }
 }
 return $multipage;
}
/**
 * 返回分頁路徑
 *
 * @param $urlrule 分頁規(guī)則
 * @param $page 當(dāng)前頁
 * @param $array 需要傳遞的數(shù)組,用于增加額外的方法
 * @return 完整的URL路徑
 */
function pageurl($urlrule, $page, $array = array()) {
 if(strpos($urlrule, &#39;~&#39;)) {
  $urlrules = explode(&#39;~&#39;, $urlrule);
  $urlrule = $page < 2 ? $urlrules[0] : $urlrules[1];
 }
 $findme = array(&#39;{$page}&#39;);
 $replaceme = array($page);
 if (is_array($array)) foreach ($array as $k=>$v) {
  $findme[] = &#39;{$&#39;.$k.&#39;}&#39;;
  $replaceme[] = $v;
 }
 $url = str_replace($findme, $replaceme, $urlrule);
 $url = str_replace(array(&#39;http://&#39;,&#39;//&#39;,&#39;~&#39;), array(&#39;~&#39;,&#39;/&#39;,&#39;http://&#39;), $url);
 return $url;
}
/**
 * URL路徑解析,pages 函數(shù)的輔助函數(shù)
 *
 * @param $par 傳入需要解析的變量 默認(rèn)為,page={$page}
 * @param $url URL地址
 * @return URL
 */
function url_par($par, $url = &#39;&#39;) {
 if($url == &#39;&#39;) $url = get_url();
 $pos = strpos($url, &#39;?&#39;);
 if($pos === false) {
  $url .= &#39;?&#39;.$par;
 } else {
  $querystring = substr(strstr($url, &#39;?&#39;), 1);
  parse_str($querystring, $pars);
  $query_array = array();
  foreach($pars as $k=>$v) {
   if($k != &#39;page&#39;) $query_array[$k] = $v;
  }
  $querystring = http_build_query($query_array).&#39;&&#39;.$par;
  $url = substr($url, 0, $pos).&#39;?&#39;.$querystring;
 }
 return $url;
}
/**
 * 判斷email格式是否正確
 * @param $email
 */
function is_email($email) {
 return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email);
}
/**
 * iconv 編輯轉(zhuǎn)換
 */
if (!function_exists(&#39;iconv&#39;)) {
 function iconv($in_charset, $out_charset, $str) {
  $in_charset = strtoupper($in_charset);
  $out_charset = strtoupper($out_charset);
  if (function_exists(&#39;mb_convert_encoding&#39;)) {
   return mb_convert_encoding($str, $out_charset, $in_charset);
  } else {
   app_base::load_sys_func(&#39;iconv&#39;);
   $in_charset = strtoupper($in_charset);
   $out_charset = strtoupper($out_charset);
   if ($in_charset == &#39;UTF-8&#39; && ($out_charset == &#39;GBK&#39; || $out_charset == &#39;GB2312&#39;)) {
    return utf8_to_gbk($str);
   }
   if (($in_charset == &#39;GBK&#39; || $in_charset == &#39;GB2312&#39;) && $out_charset == &#39;UTF-8&#39;) {
    return gbk_to_utf8($str);
   }
   return $str;
  }
 }
}
/**
 * 代碼廣告展示函數(shù)
 * @param intval $siteid 所屬站點(diǎn)
 * @param intval $id 廣告ID
 * @return 返回廣告代碼
 */
function show_ad($siteid, $id) {
 $siteid = intval($siteid);
 $id = intval($id);
 if(!$id || !$siteid) return false;
 $p = app_base::load_model(&#39;poster_model&#39;);
 $r = $p->get_one(array(&#39;spaceid&#39;=>$id, &#39;siteid&#39;=>$siteid), &#39;disabled, setting&#39;, &#39;id ASC&#39;);
 if ($r[&#39;disabled&#39;]) return &#39;&#39;;
 if ($r[&#39;setting&#39;]) {
  $c = string2array($r[&#39;setting&#39;]);
 } else {
  $r[&#39;code&#39;] = &#39;&#39;;
 }
 return $c[&#39;code&#39;];
}
/**
 * 獲取當(dāng)前的站點(diǎn)ID
 */
function get_siteid() {
 static $siteid;
 if (!empty($siteid)) return $siteid;
 if (defined(&#39;IN_ADMIN&#39;)) {
  if ($d = param::get_cookie(&#39;siteid&#39;)) {
   $siteid = $d;
  } else {
   return &#39;&#39;;
  }
 } else {
  $data = getcache(&#39;sitelist&#39;, &#39;commons&#39;);
  if(!is_array($data)) return &#39;1&#39;;
  $site_url = SITE_PROTOCOL.SITE_URL;
  foreach ($data as $v) {
   if ($v[&#39;url&#39;] == $site_url.&#39;/&#39;) $siteid = $v[&#39;siteid&#39;];
  }
 }
 if (empty($siteid)) $siteid = 1;
 return $siteid;
}
/**
 * 獲取用戶昵稱
 * 不傳入userid取當(dāng)前用戶nickname,如果nickname為空取username
 * 傳入field,取用戶$field字段信息
 */
function get_nickname($userid=&#39;&#39;, $field=&#39;&#39;) {
 $return = &#39;&#39;;
 if(is_numeric($userid)) {
  $member_db = app_base::load_model(&#39;member_model&#39;);
  $memberinfo = $member_db->get_one(array(&#39;userid&#39;=>$userid));
  if(!empty($field) && $field != &#39;nickname&#39; && isset($memberinfo[$field]) &&!empty($memberinfo[$field])) {
   $return = $memberinfo[$field];
  } else {
   $return = isset($memberinfo[&#39;nickname&#39;]) && !empty($memberinfo[&#39;nickname&#39;]) ? $memberinfo[&#39;nickname&#39;].&#39;(&#39;.$memberinfo[&#39;username&#39;].&#39;)&#39; : $memberinfo[&#39;username&#39;];
  }
 } else {
  if (param::get_cookie(&#39;_nickname&#39;)) {
   $return .= &#39;(&#39;.param::get_cookie(&#39;_nickname&#39;).&#39;)&#39;;
  } else {
   $return .= &#39;(&#39;.param::get_cookie(&#39;_username&#39;).&#39;)&#39;;
  }
 }
 return $return;
}
/**
 * 獲取用戶信息
 * 不傳入$field返回用戶所有信息,
 * 傳入field,取用戶$field字段信息
 */
function get_memberinfo($userid, $field=&#39;&#39;) {
 if(!is_numeric($userid)) {
  return false;
 } else {
  static $memberinfo;
  if (!isset($memberinfo[$userid])) {
   $member_db = app_base::load_model(&#39;member_model&#39;);
   $memberinfo[$userid] = $member_db->get_one(array(&#39;userid&#39;=>$userid));
  }
  if(!empty($field) && !empty($memberinfo[$userid][$field])) {
   return $memberinfo[$userid][$field];
  } else {
   return $memberinfo[$userid];
  }
 }
}
/**
 * 通過 username 值,獲取用戶所有信息
 * 獲取用戶信息
 * 不傳入$field返回用戶所有信息,
 * 傳入field,取用戶$field字段信息
 */
function get_memberinfo_buyusername($username, $field=&#39;&#39;) {
 if(empty($username)){return false;}
 static $memberinfo;
 if (!isset($memberinfo[$username])) {
  $member_db = app_base::load_model(&#39;member_model&#39;);
  $memberinfo[$username] = $member_db->get_one(array(&#39;username&#39;=>$username));
 }
 if(!empty($field) && !empty($memberinfo[$username][$field])) {
  return $memberinfo[$username][$field];
 } else {
  return $memberinfo[$username];
 }
}
/**
 * 調(diào)用關(guān)聯(lián)菜單
 * @param $linkageid 聯(lián)動菜單id
 * @param $id 生成聯(lián)動菜單的樣式id
 * @param $defaultvalue 默認(rèn)值
 */
function menu_linkage($linkageid = 0, $id = &#39;linkid&#39;, $defaultvalue = 0, $defaultlabel = array()) {
 $linkageid = intval($linkageid);
 $datas = array();
 $datas = getcache($linkageid,&#39;linkage&#39;);
 $infos = $datas[&#39;data&#39;];
 if($datas[&#39;style&#39;]==&#39;1&#39;) {
  $title = $datas[&#39;title&#39;];
  $container = &#39;content&#39;.create_randomnum(100, 999).date(&#39;is&#39;);
  if(!defined(&#39;DIALOG_INIT_1&#39;)) {
   define(&#39;DIALOG_INIT_1&#39;, 1);
   $string .= &#39;<script type="text/javascript" src="&#39;.JS_PATH.&#39;dialog.js"></script>&#39;;
   //TODO $string .= &#39;<link href="&#39;.CSS_PATH.&#39;dialog.css" rel="stylesheet" type="text/css">&#39;;
  }
  if(!defined(&#39;LINKAGE_INIT_1&#39;)) {
   define(&#39;LINKAGE_INIT_1&#39;, 1);
   $string .= &#39;<script type="text/javascript" src="&#39;.JS_PATH.&#39;linkage/js/pop.js"></script>&#39;;
  }
  $var_p = $defaultvalue && (ROUTE_A==&#39;edit&#39; || ROUTE_A==&#39;account_manage_info&#39; || ROUTE_A==&#39;info_publish&#39; || ROUTE_A==&#39;orderinfo&#39;) ? 
  menu_linkage_level($defaultvalue,$linkageid,$infos) : $datas[&#39;title&#39;];
  $var_input = $defaultvalue && (ROUTE_A==&#39;edit&#39; || ROUTE_A==&#39;account_manage_info&#39; || ROUTE_A==&#39;info_publish&#39;) ? &#39;<input type="hidden" name="info[&#39;.$id.&#39;]" 
  value="&#39;.$defaultvalue.&#39;">&#39; : &#39;<input type="hidden" name="info[&#39;.$id.&#39;]" value="">&#39;;
  $string .= &#39;<p name="&#39;.$id.&#39;" value="" id="&#39;.$id.&#39;" class="ib">&#39;.$var_p.&#39;</p>&#39;.$var_input.&#39; <input type="button" name="btn_&#39;.$id.&#39;" class="button" 
  value="&#39;.L(&#39;linkage_select&#39;).&#39;" >  $string .= &#39;<script type="text/javascript">&#39;;
  $string .= &#39;var returnid_&#39;.$id.&#39;= \&#39;&#39;.$id.&#39;\&#39;;&#39;;
  $string .= &#39;var returnkeyid_&#39;.$id.&#39; = \&#39;&#39;.$linkageid.&#39;\&#39;;&#39;;
  $string .= &#39;var &#39;.$container.&#39; = new Array(&#39;;
  foreach($infos AS $k=>$v) {
   if($v[&#39;parentid&#39;] == 0) {
    $s[]=&#39;new Array(\&#39;&#39;.$v[&#39;linkageid&#39;].&#39;\&#39;,\&#39;&#39;.$v[&#39;name&#39;].&#39;\&#39;,\&#39;&#39;.$v[&#39;parentid&#39;].&#39;\&#39;)&#39;;
   } else {
    continue;
   }
  }
  $s = implode(&#39;,&#39;,$s);
  $string .=$s;
  $string .= &#39;)&#39;;
  $string .= &#39;</script>&#39;;
 } elseif($datas[&#39;style&#39;]==&#39;2&#39;) {
  if(!defined(&#39;LINKAGE_INIT_1&#39;)) {
   define(&#39;LINKAGE_INIT_1&#39;, 1);
   $string .= &#39;<script type="text/javascript" src="&#39;.JS_PATH.&#39;linkage/js/jquery.ld.js"></script>&#39;;
  }
  $default_txt = &#39;&#39;;
  if($defaultvalue) {
    $default_txt = menu_linkage_level($defaultvalue,$linkageid,$infos);
    $default_txt = &#39;["&#39;.str_replace(&#39; > &#39;,&#39;","&#39;,$default_txt).&#39;"]&#39;;
  }
  $string .= $defaultvalue && (ROUTE_A==&#39;edit&#39; || ROUTE_A==&#39;account_manage_info&#39; || ROUTE_A==&#39;info_publish&#39;) ? &#39;<input type="hidden" name="info[&#39;.$id.&#39;]" id="&#39;.$id.&#39;" value="&#39;.$defaultvalue.&#39;">&#39; : &#39;<input type="hidden" name="info[&#39;.$id.&#39;]" id="&#39;.$id.&#39;" value="">&#39;;
  for($i=1;$i<=$datas[&#39;setting&#39;][&#39;level&#39;];$i++) {
   $txt = isset($defaultlabel[$i]) ? $defaultlabel[$i] : &#39;請選擇&#39;;
   $string .=&#39;<select class="pc-select-&#39;.$id.&#39;" name="&#39;.$id.&#39;-&#39;.$i.&#39;" id="&#39;.$id.&#39;-&#39;.$i.&#39;" width="100"><option value="">&#39; . $txt . &#39;</option></select> &#39;;
  }
  $string .= &#39;<script type="text/javascript">
     $(function(){
      var $ld5 = $(".pc-select-&#39;.$id.&#39;");
      $ld5.ld({ajaxOptions : {"url" : "&#39;.APP_PATH.&#39;api.php?op=get_linkage&act=ajax_select&keyid=&#39;.$linkageid.&#39;"},defaultParentId : 0,style : {"width" : 120}})
      var ld5_api = $ld5.ld("api");
      //ld5_api.selected(&#39;.$default_txt.&#39;);
      $ld5.bind("change",onchange);
      function onchange(e){
       var $target = $(e.target);
       var index = $ld5.index($target);
       $("#&#39;.$id.&#39;-&#39;.$i.&#39;").remove();
       $("#&#39;.$id.&#39;").val($ld5.eq(index).show().val());
       index ++;
       $ld5.eq(index).show();        }
     })
  </script>&#39;;
 } else {
  $title = $defaultvalue ? $infos[$defaultvalue][&#39;name&#39;] : $datas[&#39;title&#39;];
  $colObj = create_randomnum(100, 999).date(&#39;is&#39;);
  $string = &#39;&#39;;
  if(!defined(&#39;LINKAGE_INIT&#39;)) {
   define(&#39;LINKAGE_INIT&#39;, 1);
   $string .= &#39;<script type="text/javascript" src="&#39;.JS_PATH.&#39;linkage/js/mln.colselect.js"></script>&#39;;
   if(defined(&#39;IN_ADMIN&#39;)) {
    $string .= &#39;<link href="&#39;.JS_PATH.&#39;linkage/style/admin.css" rel="stylesheet" type="text/css">&#39;;
   } else {
    $string .= &#39;<link href="&#39;.JS_PATH.&#39;linkage/style/css.css" rel="stylesheet" type="text/css">&#39;;
   }
  }
  $string .= &#39;<input type="hidden" name="info[&#39;.$id.&#39;]" value="1"><p id="&#39;.$id.&#39;"></p>&#39;;
  $string .= &#39;<script type="text/javascript">&#39;;
  $string .= &#39;var colObj&#39;.$colObj.&#39; = {"Items":[&#39;;
  foreach($infos AS $k=>$v) {
   $s .= &#39;{"name":"&#39;.$v[&#39;name&#39;].&#39;","topid":"&#39;.$v[&#39;parentid&#39;].&#39;","colid":"&#39;.$k.&#39;","value":"&#39;.$k.&#39;","fun":function(){}},&#39;;
  }
  $string .= substr($s, 0, -1);
  $string .= &#39;]};&#39;;
  $string .= &#39;$("#&#39;.$id.&#39;").mlnColsel(colObj&#39;.$colObj.&#39;,{&#39;;
  $string .= &#39;title:"&#39;.$title.&#39;",&#39;;
  $string .= &#39;value:"&#39;.$defaultvalue.&#39;",&#39;;
  $string .= &#39;width:100&#39;;
  $string .= &#39;});&#39;;
  $string .= &#39;</script>&#39;;
 }
 return $string;
}
/**
 * 聯(lián)動菜單層級
 */
function menu_linkage_level($linkageid,$keyid,$infos,$result=array()) {
 if(array_key_exists($linkageid,$infos)) {
  $result[]=$infos[$linkageid][&#39;name&#39;];
  return menu_linkage_level($infos[$linkageid][&#39;parentid&#39;],$keyid,$infos,$result);
 }
 krsort($result);
 return implode(&#39; > &#39;,$result);
}
/**
 * 通過catid獲取顯示菜單完整結(jié)構(gòu)
 * @param $menuid 菜單ID
 * @param $cache_file 菜單緩存文件名稱
 * @param $cache_path 緩存文件目錄
 * @param $key 取得緩存值的鍵值名稱
 * @param $parentkey 父級的ID
 * @param $linkstring 鏈接字符
 */
function menu_level($menuid, $cache_file, $cache_path = &#39;commons&#39;, $key = &#39;catname&#39;, $parentkey = &#39;parentid&#39;, $linkstring = &#39; > &#39;, $result=array()) {
 $menu_arr = getcache($cache_file, $cache_path);
 if (array_key_exists($menuid, $menu_arr)) {
  $result[] = $menu_arr[$menuid][$key];
  return menu_level($menu_arr[$menuid][$parentkey], $cache_file, $cache_path, $key, $parentkey, $linkstring, $result);
 }
 krsort($result);
 return implode($linkstring, $result);
}
/**
 * 通過id獲取顯示聯(lián)動菜單
 * @param $linkageid 聯(lián)動菜單ID
 * @param $keyid 菜單keyid
 * @param $space 菜單間隔符
 * @param $tyoe 1 返回間隔符鏈接,完整路徑名稱 3 返回完整路徑數(shù)組,2返回當(dāng)前聯(lián)動菜單名稱,4 直接返回ID
 * @param $result 遞歸使用字段1
 * @param $infos 遞歸使用字段2
 */
function get_linkage($linkageid, $keyid, $space = &#39;>&#39;, $type = 1, $result = array(), $infos = array()) {
 if($space==&#39;&#39; || !isset($space))$space = &#39;>&#39;;
 if(!$infos) {
  $datas = getcache($keyid,&#39;linkage&#39;);
  $infos = $datas[&#39;data&#39;];
 }
 if($type == 1 || $type == 3 || $type == 4) {
  if(array_key_exists($linkageid,$infos)) {
   $result[]= ($type == 1) ? $infos[$linkageid][&#39;name&#39;] : (($type == 4) ? $linkageid :$infos[$linkageid]);
   return get_linkage($infos[$linkageid][&#39;parentid&#39;], $keyid, $space, $type, $result, $infos);
  } else {
   if(count($result)>0) {
    krsort($result);
    if($type == 1 || $type == 4) $result = implode($space,$result);
    return $result;
   } else {
    return $result;
   }
  }
 } else {
  return $infos[$linkageid][&#39;name&#39;];
 }
}
/**
 * IE瀏覽器判斷
 */
function is_ie() {
 $useragent = strtolower($_SERVER[&#39;HTTP_USER_AGENT&#39;]);
 if((strpos($useragent, &#39;opera&#39;) !== false) || (strpos($useragent, &#39;konqueror&#39;) !== false)) return false;
 if(strpos($useragent, &#39;msie &#39;) !== false) return true;
 return false;
}
/**
 * 文件下載
 * @param $filepath 文件路徑
 * @param $filename 文件名稱
 */
function file_down($filepath, $filename = &#39;&#39;) {
 if(!$filename) $filename = basename($filepath);
 if(is_ie()) $filename = rawurlencode($filename);
 $filetype = fileext($filename);
 $filesize = sprintf("%u", filesize($filepath));
 if(ob_get_length() !== false) @ob_end_clean();
 header(&#39;Pragma: public&#39;);
 header(&#39;Last-Modified: &#39;.gmdate(&#39;D, d M Y H:i:s&#39;) . &#39; GMT&#39;);
 header(&#39;Cache-Control: no-store, no-cache, must-revalidate&#39;);
 header(&#39;Cache-Control: pre-check=0, post-check=0, max-age=0&#39;);
 header(&#39;Content-Transfer-Encoding: binary&#39;);
 header(&#39;Content-Encoding: none&#39;);
 header(&#39;Content-type: &#39;.$filetype);
 header(&#39;Content-Disposition: attachment; filename="&#39;.$filename.&#39;"&#39;);
 header(&#39;Content-length: &#39;.$filesize);
 readfile($filepath);
 exit;
}
/**
 * 判斷字符串是否為utf8編碼,英文和半角字符返回ture
 * @param $string
 * @return bool
 */
function is_utf8($string) {
 return preg_match(&#39;%^(?:
     [\x09\x0A\x0D\x20-\x7E] # ASCII
     | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
     | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
     | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
     | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
     | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
     | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
     | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
     )*$%xs&#39;, $string);
}
/**
 * 組裝生成ID號
 * @param $modules 模塊名
 * @param $contentid 內(nèi)容ID
 * @param $siteid 站點(diǎn)ID
 */
function id_encode($modules,$contentid, $siteid) {
 return urlencode($modules.&#39;-&#39;.$contentid.&#39;-&#39;.$siteid);
}
/**
 * 解析ID
 * @param $id 評論ID
 */
function id_decode($id) {
 return explode(&#39;-&#39;, $id);
}
/**
 * 對用戶的密碼進(jìn)行加密
 * @param $password
 * @param $encrypt //傳入加密串,在修改密碼時做認(rèn)證
 * @return array/password
 */
function password($password, $encrypt=&#39;&#39;) {
 $pwd = array();
 $pwd[&#39;encrypt&#39;] = $encrypt ? $encrypt : create_randomstr();
 $pwd[&#39;password&#39;] = md5(md5(trim($password)).$pwd[&#39;encrypt&#39;]);
 return $encrypt ? $pwd[&#39;password&#39;] : $pwd;
}
/**
 * 生成隨機(jī)字符串
 * @param string $lenth 長度
 * @return string 字符串
 */
function create_randomstr($lenth = 6) {
 //openssl_random_pseudo_bytes
 $fp = @fopen(&#39;/dev/urandom&#39;,&#39;rb&#39;);
 $pr_bits = &#39;&#39;;
 if ($fp !== FALSE) {
  $pr_bits .= @fread($fp,$lenth/2);
  @fclose($fp);
 }
 return bin2hex($pr_bits);
 //return random($lenth, &#39;123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ&#39;);
}
/**
 * 生成隨機(jī)數(shù)
 * @param string $lenth 長度
 * @return string 字符串
 */
function create_randomnum($min,$max) {
 //openssl_random_pseudo_bytes
 $difference = $max-$min;
 $bytesNeeded = ceil($difference/256);
 $fp = @fopen(&#39;/dev/urandom&#39;,&#39;rb&#39;);
 if ($fp !== FALSE) {
  $randomBytes = @fread($fp,$bytesNeeded);
  @fclose($fp);
 }
 $sum = 0;
 for ($a = 0; $a < $bytesNeeded; $a++){
  $sum += ord($randomBytes[$a]);
 }
 $sum = $sum % ($difference);
 return $sum + $min;
 //return random($lenth, &#39;123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ&#39;);
}
/**
 * 檢查密碼長度是否符合規(guī)定
 *
 * @param STRING $password
 * @return  TRUE or FALSE
 */
function is_password($password) {
 $strlen = strlen($password);
 if($strlen >= 6 && $strlen <= 20) return true;
 return false;
}
 /**
 * 檢測輸入中是否含有錯誤字符
 *
 * @param char $string 要檢查的字符串名稱
 * @return TRUE or FALSE
 */
function is_badword($string) {
 $badwords = array("\\",&#39;&&#39;,&#39; &#39;,"&#39;",&#39;"&#39;,&#39;/&#39;,&#39;*&#39;,&#39;,&#39;,&#39;<&#39;,&#39;>&#39;,"\r","\t","\n","#");
 foreach($badwords as $value){
  if(strpos($string, $value) !== FALSE) {
   return TRUE;
  }
 }
 return FALSE;
}
/**
 * 檢查用戶名是否符合規(guī)定
 *
 * @param STRING $username 要檢查的用戶名
 * @return  TRUE or FALSE
 */
function is_username($username) {
 $strlen = strlen($username);
 if(is_badword($username) || !preg_match("/^[a-zA-Z0-9_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+$/", $username)){
  return false;
 } elseif ( 20 < $strlen || $strlen < 2 ) {
  return false;
 }
 return true;
}
/**
 * 檢查id是否存在于數(shù)組中
 *
 * @param $id
 * @param $ids
 * @param $s
 */
function check_in($id, $ids = &#39;&#39;, $s = &#39;,&#39;) {
 if(!$ids) return false;
 $ids = explode($s, $ids);
 return is_array($id) ? array_intersect($id, $ids) : in_array($id, $ids);
}
/**
 * 對數(shù)據(jù)進(jìn)行編碼轉(zhuǎn)換
 * @param array/string $data  數(shù)組
 * @param string $input  需要轉(zhuǎn)換的編碼
 * @param string $output 轉(zhuǎn)換后的編碼
 */
function array_iconv($data, $input = &#39;gbk&#39;, $output = &#39;utf-8&#39;) {
 if (!is_array($data)) {
  return iconv($input, $output, $data);
 } else {
  foreach ($data as $key=>$val) {
   if(is_array($val)) {
    $data[$key] = array_iconv($val, $input, $output);
   } else {
    $data[$key] = iconv($input, $output, $val);
   }
  }
  return $data;
 }
}
/**
 * 生成縮略圖函數(shù)
 * @param $imgurl 圖片路徑
 * @param $width 縮略圖寬度
 * @param $height 縮略圖高度
 * @param $autocut 是否自動裁剪 默認(rèn)裁剪,當(dāng)高度或?qū)挾扔幸粋€數(shù)值為0是,自動關(guān)閉
 * @param $smallpic 無圖片是默認(rèn)圖片路徑
 */
function thumb($imgurl, $width = 100, $height = 100 ,$autocut = 1, $smallpic = &#39;nopic.gif&#39;) {
 global $image;
 $upload_url = app_base::load_config(&#39;system&#39;,&#39;upload_url&#39;);
 $upload_path = app_base::load_config(&#39;system&#39;,&#39;upload_path&#39;);
 if(empty($imgurl)) return IMG_PATH.$smallpic;
 $imgurl_replace= str_replace($upload_url, &#39;&#39;, $imgurl);
 if(!extension_loaded(&#39;gd&#39;) || strpos($imgurl_replace, &#39;://&#39;)) return $imgurl;
 if(!file_exists($upload_path.$imgurl_replace)) return IMG_PATH.$smallpic;
 list($width_t, $height_t, $type, $attr) = getimagesize($upload_path.$imgurl_replace);
 if($width>=$width_t || $height>=$height_t) return $imgurl;
 $newimgurl = dirname($imgurl_replace).&#39;/thumb_&#39;.$width.&#39;_&#39;.$height.&#39;_&#39;.basename($imgurl_replace);
 if(file_exists($upload_path.$newimgurl)) return $upload_url.$newimgurl;
 if(!is_object($image)) {
  app_base::load_sys_class(&#39;image&#39;,&#39;&#39;,&#39;0&#39;);
  $image = new image(1,0);
 }
 return $image->thumb($upload_path.$imgurl_replace, $upload_path.$newimgurl, $width, $height, &#39;&#39;, $autocut) ? $upload_url.$newimgurl : $imgurl;
}
/**
 * 水印添加
 * @param $source 原圖片路徑
 * @param $target 生成水印圖片途徑,默認(rèn)為空,覆蓋原圖
 * @param $siteid 站點(diǎn)id,系統(tǒng)需根據(jù)站點(diǎn)id獲取水印信息
 */
function watermark($source, $target = &#39;&#39;,$siteid) {
 global $image_w;
 if(empty($source)) return $source;
 if(!extension_loaded(&#39;gd&#39;) || strpos($source, &#39;://&#39;)) return $source;
 if(!$target) $target = $source;
 if(!is_object($image_w)){
  app_base::load_sys_class(&#39;image&#39;,&#39;&#39;,&#39;0&#39;);
  $image_w = new image(0,$siteid);
 }
  $image_w->watermark($source, $target);
 return $target;
}
/**
 * 當(dāng)前路徑
 * 返回指定欄目路徑層級
 * @param $catid 欄目id
 * @param $symbol 欄目間隔符
 */
function catpos($catid, $symbol=&#39; > &#39;){
 $category_arr = array();
 $siteids = getcache(&#39;category_content&#39;,&#39;commons&#39;);
 $siteid = $siteids[$catid];
 $category_arr = getcache(&#39;category_content_&#39;.$siteid,&#39;commons&#39;);
 if(!isset($category_arr[$catid])) return &#39;&#39;;
 $pos = &#39;&#39;;
 $siteurl = siteurl($category_arr[$catid][&#39;siteid&#39;]);
 $arrparentid = array_filter(explode(&#39;,&#39;, $category_arr[$catid][&#39;arrparentid&#39;].&#39;,&#39;.$catid));
 foreach($arrparentid as $catid) {
  $url = $category_arr[$catid][&#39;url&#39;];
 // if(strpos($url, &#39;://&#39;) === false) $url = $siteurl.$url;
  $pos .= &#39;<a href="&#39;.$url.&#39;">&#39;.$category_arr[$catid][&#39;catname&#39;].&#39;</a>&#39;.$symbol;
 }
 return $pos;
}
/**
 * 根據(jù)catid獲取子欄目數(shù)據(jù)的sql語句
 * @param string $module 緩存文件名
 * @param intval $catid 欄目ID
 */
function get_sql_catid($file = &#39;category_content_1&#39;, $catid = 0, $module = &#39;commons&#39;) {
 $category = getcache($file,$module);
 $catid = intval($catid);
 if(!isset($category[$catid])) return false;
 return $category[$catid][&#39;child&#39;] ? " catid IN(".$category[$catid][&#39;arrchildid&#39;].") " : " catid=$catid ";
}
/**
 * 獲取子欄目
 * @param $parentid 父級id
 * @param $type 欄目類型
 * @param $self 是否包含本身 0為不包含
 * @param $siteid 站點(diǎn)id
 */
function subcat($parentid = NULL, $type = NULL,$self = &#39;0&#39;, $siteid = &#39;&#39;) {
 if (empty($siteid)) $siteid = get_siteid();
 $category = getcache(&#39;category_content_&#39;.$siteid,&#39;commons&#39;);
 foreach($category as $id=>$cat) {
  if($cat[&#39;siteid&#39;] == $siteid && ($parentid === NULL || $cat[&#39;parentid&#39;] == $parentid) && ($type === NULL || $cat[&#39;type&#39;] == $type)) $subcat[$id] = $cat;
  if($self == 1 && $cat[&#39;catid&#39;] == $parentid && !$cat[&#39;child&#39;]) $subcat[$id] = $cat;
 }
 return $subcat;
}
/**
 * 獲取內(nèi)容地址
 * @param $catid 欄目ID
 * @param $id  文章ID
 * @param $allurl 是否以絕對路徑返回
 */
function go($catid,$id, $allurl = 0) {
 static $category;
 if(empty($category)) {
  $siteids = getcache(&#39;category_content&#39;,&#39;commons&#39;);
  $siteid = $siteids[$catid];
  $category = getcache(&#39;category_content_&#39;.$siteid,&#39;commons&#39;);
 }
 $id = intval($id);
 if(!$id || !isset($category[$catid])) return &#39;&#39;;
 $modelid = $category[$catid][&#39;modelid&#39;];
 if(!$modelid) return &#39;&#39;;
 $db = app_base::load_model(&#39;content_model&#39;);
 $db->set_model($modelid);
 $r = $db->setCache()->get_one(array(&#39;id&#39;=>$id), &#39;url&#39;);
 if (!empty($allurl)) {
  if (strpos($r[&#39;url&#39;], &#39;://&#39;)===false) {
   if (strpos($category[$catid][&#39;url&#39;], &#39;://&#39;) === FALSE) {
    $site = siteinfo($category[$catid][&#39;siteid&#39;]);
    $r[&#39;url&#39;] = substr($site[&#39;domain&#39;], 0, -1).$r[&#39;url&#39;];
   } else {
    $r[&#39;url&#39;] = $category[$catid][&#39;url&#39;].$r[&#39;url&#39;];
   }
  }
 }
 return $r[&#39;url&#39;];
}
/**
 * 將附件地址轉(zhuǎn)換為絕對地址
 * @param $path 附件地址
 */
function atturl($path) {
 if(strpos($path, &#39;:/&#39;)) {
  return $path;
 } else {
  $sitelist = getcache(&#39;sitelist&#39;,&#39;commons&#39;);
  $siteid = get_siteid();
  $siteurl = $sitelist[$siteid][&#39;domain&#39;];
  $domainlen = strlen($sitelist[$siteid][&#39;domain&#39;])-1;
  $path = $siteurl.$path;
  $path = substr_replace($path, &#39;/&#39;, strpos($path, &#39;//&#39;,$domainlen),2);
  return  $path;
 }
}
/**
 * 判斷模塊是否安裝
 * @param $m 模塊名稱
 */
function module_exists($m = &#39;&#39;) {
 if ($m==&#39;admin&#39;) return true;
 $modules = getcache(&#39;modules&#39;, &#39;commons&#39;);
 $modules = array_keys($modules);
 return in_array($m, $modules);
}
/**
 * 生成SEO
 * @param $siteid  站點(diǎn)ID
 * @param $catid  欄目ID
 * @param $title  標(biāo)題
 * @param $description 描述
 * @param $keyword  關(guān)鍵詞
 */
function seo($siteid, $catid = &#39;&#39;, $title = &#39;&#39;, $description = &#39;&#39;, $keyword = &#39;&#39;) {
 if (!empty($title))$title = strip_tags($title);
 if (!empty($description)) $description = strip_tags($description);
 if (!empty($keyword)) $keyword = str_replace(&#39; &#39;, &#39;,&#39;, strip_tags($keyword));
 $sites = getcache(&#39;sitelist&#39;, &#39;commons&#39;);
 $site = $sites[$siteid];
 $cat = array();
 if (!empty($catid)) {
  $siteids = getcache(&#39;category_content&#39;,&#39;commons&#39;);
  $siteid = $siteids[$catid];
  $categorys = getcache(&#39;category_content_&#39;.$siteid,&#39;commons&#39;);
  $cat = $categorys[$catid];
  $cat[&#39;setting&#39;] = string2array($cat[&#39;setting&#39;]);
 }
 $seo[&#39;site_title&#39;] =isset($site[&#39;site_title&#39;]) && !empty($site[&#39;site_title&#39;]) ? $site[&#39;site_title&#39;] : $site[&#39;name&#39;];
 $seo[&#39;keyword&#39;] = !empty($keyword) ? $keyword : $site[&#39;keywords&#39;];
 $seo[&#39;description&#39;] = isset($description) && !empty($description) ? $description : (isset($cat[&#39;setting&#39;][&#39;meta_description&#39;]) && 
 !empty($cat[&#39;setting&#39;][&#39;meta_description&#39;]) ? $cat[&#39;setting&#39;][&#39;meta_description&#39;] : (isset($site[&#39;description&#39;]) && !empty($site[&#39;description&#39;]) 
 ? $site[&#39;description&#39;] : &#39;&#39;));
 $seo[&#39;title&#39;] = (isset($title) && !empty($title) ? $title.&#39; - &#39; : &#39;&#39;).(isset($cat[&#39;setting&#39;][&#39;meta_title&#39;]) && !empty($cat[&#39;setting&#39;][&#39;meta_title&#39;]) ?
  $cat[&#39;setting&#39;][&#39;meta_title&#39;].&#39; - &#39; : (isset($cat[&#39;catname&#39;]) && !empty($cat[&#39;catname&#39;]) ? $cat[&#39;catname&#39;].&#39; - &#39; : &#39;&#39;));
 foreach ($seo as $k=>$v) {
  $seo[$k] = str_replace(array("\n","\r"), &#39;&#39;, $v);
 }
 return $seo;
}
/**
 * 獲取站點(diǎn)的信息
 * @param $siteid 站點(diǎn)ID
 */
function siteinfo($siteid) {
 static $sitelist;
 if (empty($sitelist)) $sitelist = getcache(&#39;sitelist&#39;,&#39;commons&#39;);
 return isset($sitelist[$siteid]) ? $sitelist[$siteid] : &#39;&#39;;
}
/**
 * 生成CNZZ統(tǒng)計代碼
 */
function tjcode() {
 if(!module_exists(&#39;cnzz&#39;)) return false;
 $config = getcache(&#39;cnzz&#39;, &#39;commons&#39;);
 if (empty($config)) {
  return false;
 } else {
  return &#39;<script src=\&#39;http://pw.#/c.php?id=&#39;.$config[&#39;siteid&#39;].&#39;&l=2\&#39; language=\&#39;JavaScript\&#39; charset=\&#39;gb2312\&#39;></script>&#39;;
 }
}
/**
 * 生成標(biāo)題樣式
 * @param $style 樣式
 * @param $html 是否顯示完整的STYLE
 */
function title_style($style, $html = 1) {
 $str = &#39;&#39;;
 if ($html) $str = &#39; style="&#39;;
 $style_arr = explode(&#39;;&#39;,$style);
 if (!empty($style_arr[0])) $str .= &#39;color:&#39;.$style_arr[0].&#39;;&#39;;
 if (!empty($style_arr[1])) $str .= &#39;font-weight:&#39;.$style_arr[1].&#39;;&#39;;
 if ($html) $str .= &#39;" &#39;;
 return $str;
}
/**
 * 獲取站點(diǎn)域名
 * @param $siteid 站點(diǎn)id
 */
function siteurl($siteid) {
 static $sitelist;
 return WEB_PATH;
// if(!$siteid) return WEB_PATH;
// if(empty($sitelist)) $sitelist = getcache(&#39;sitelist&#39;,&#39;commons&#39;);
// return substr($sitelist[$siteid][&#39;domain&#39;],0,-1);
}
/**
 * 生成上傳附件驗(yàn)證
 * @param $args 參數(shù)
 * @param $operation 操作類型(加密解密)
 */
function upload_key($args) {
 $pc_auth_key = md5(app_base::load_config(&#39;system&#39;,&#39;auth_key&#39;).$_SERVER[&#39;HTTP_USER_AGENT&#39;]);
 $authkey = md5($args.$pc_auth_key);
 return $authkey;
}
/**
 * 文本轉(zhuǎn)換為圖片
 * @param string $txt 圖形化文本內(nèi)容
 * @param int $fonttype 無外部字體時生成文字大小,取值范圍1-5
 * @param int $fontsize 引入外部字體時,字體大小
 * @param string $font 字體名稱 字體請放于app\libs\data\font下
 * @param string $fontcolor 字體顏色 十六進(jìn)制形式 如FFFFFF,FF0000
 */
function string2img($txt, $fonttype = 5, $fontsize = 16, $font = &#39;&#39;, $fontcolor = &#39;FF0000&#39;,$transparent = &#39;1&#39;) {
 if(empty($txt)) return false;
 if(function_exists("imagepng")) {
  $txt = urlencode(sys_auth($txt));
  $txt = &#39;<img src="&#39;.APP_PATH.&#39;api.php?op=creatimg&txt=&#39;.$txt.&#39;&f &#39;.$version[&#39;pc_release&#39;];
 }
}
/**
 * 運(yùn)行鉤子(插件使用)
 */
function runhook($method) {
 $time_start = getmicrotime();
 $data = &#39;&#39;;
 $getpclass = FALSE;
 $hook_appid = getcache(&#39;hook&#39;,&#39;plugins&#39;);
 if(!empty($hook_appid)) {
  foreach($hook_appid as $appid => $p) {
   $pluginfilepath = CODE_PATH.&#39;plugin&#39;.DIRECTORY_SEPARATOR.$p.DIRECTORY_SEPARATOR.&#39;hook.class.php&#39;;
   $getpclass = TRUE;
   include_once $pluginfilepath;
  }
  $hook_appid = array_flip($hook_appid);
  if($getpclass) {
   $pclass = new ReflectionClass(&#39;hook&#39;);
   foreach($pclass->getMethods() as $r) {
    $legalmethods[] = $r->getName();
   }
  }
  if(in_array($method,$legalmethods)) {
   foreach (get_declared_classes() as $class){
    $refclass = new ReflectionClass($class);
    if($refclass->isSubclassOf(&#39;hook&#39;)){
     if ($_method = $refclass->getMethod($method)) {
       $classname = $refclass->getName();
      if ($_method->isPublic() && $_method->isFinal()) {
       plugin_stat($hook_appid[$classname]);
       $data .= $_method->invoke(null);
      }
     }
    }
   }
  }
  return $data;
 }
}
function getmicrotime() {
 list($usec, $sec) = explode(" ",microtime());
 return ((float)$usec + (float)$sec);
}
/**
 * 插件前臺模板加載
 * Enter description here ...
 * @param unknown_type $module
 * @param unknown_type $template
 * @param unknown_type $style
 */
function p_template($plugin = &#39;content&#39;, $template = &#39;index&#39;,$style=&#39;default&#39;) {
 if(!$style) $style = &#39;default&#39;;
 $template_cache = app_base::load_sys_class(&#39;template_cache&#39;);
 $compiledtplfile = ROOT_PATH.&#39;caches&#39;.DIRECTORY_SEPARATOR.&#39;caches_template&#39;.DIRECTORY_SEPARATOR.$style.DIRECTORY_SEPARATOR.&#39;plugin&#39;.DIRECTORY_SEPARATOR.
 $plugin.DIRECTORY_SEPARATOR.$template.&#39;.php&#39;;
 if(!file_exists($compiledtplfile) || (file_exists(CODE_PATH.&#39;plugin&#39;.DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR.&#39;templates&#39;
 .DIRECTORY_SEPARATOR.$template.&#39;.html&#39;) && filemtime(CODE_PATH.&#39;plugin&#39;.DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR.&#39;templates&#39;.
 DIRECTORY_SEPARATOR.$template.&#39;.html&#39;) > filemtime($compiledtplfile))) {
  $template_cache->template_compile(&#39;plugin/&#39;.$plugin, $template, &#39;default&#39;);
 } elseif (!file_exists(CODE_PATH.&#39;plugin&#39;.DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR.&#39;templates&#39;.DIRECTORY_SEPARATOR.$template.&#39;.html&#39;)) {
  showmessage(&#39;Template does not exist.&#39;.DIRECTORY_SEPARATOR.&#39;plugin&#39;.DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR.$template.&#39;.html&#39;);
 }
 return $compiledtplfile;
}
/**
 * 讀取緩存動態(tài)頁面
 */
function cache_page_start() {
 $relate_url = isset($_SERVER[&#39;REQUEST_URI&#39;]) ? safe_replace($_SERVER[&#39;REQUEST_URI&#39;]) : $php_self.(isset($_SERVER[&#39;QUERY_STRING&#39;]) ? &#39;?&#39;.
 safe_replace($_SERVER[&#39;QUERY_STRING&#39;]) : $path_info);
 define(&#39;CACHE_PAGE_ID&#39;, md5($relate_url));
 $contents = getcache(CACHE_PAGE_ID, &#39;page_tmp/&#39;.substr(CACHE_PAGE_ID, 0, 2));
 if($contents && intval(substr($contents, 15, 10)) > SYS_TIME) {
  echo substr($contents, 29);
  exit;
 }
 if (!defined(&#39;HTML&#39;)) define(&#39;HTML&#39;,true);
 return true;
}
/**
 * 寫入緩存動態(tài)頁面
 */
function cache_page($ttl = 360, $isjs = 0) {
 if($ttl == 0 || !defined(&#39;CACHE_PAGE_ID&#39;)) return false;
 $contents = ob_get_contents();
 if($isjs) $contents = format_js($contents);
 $contents = "<!--expiretime:".(SYS_TIME + $ttl)."-->\n".$contents;
 setcache(CACHE_PAGE_ID, $contents, &#39;page_tmp/&#39;.substr(CACHE_PAGE_ID, 0, 2));
}
/**
 *
 * 獲取遠(yuǎn)程內(nèi)容
 * @param $url 接口url地址
 * @param $timeout 超時時間
 */
function pc_file_get_contents($url, $timeout=30) {
 $stream = stream_context_create(array(&#39;http&#39; => array(&#39;timeout&#39; => $timeout)));
 return @file_get_contents($url, 0, $stream);
}
/**
 * Function get_vid
 * 獲取視頻信息
 * @param int $contentid 內(nèi)容ID 必須
 * @param int $catid 欄目id 取內(nèi)容里面視頻信息時必須
 * @param int $isspecial 是否取專題的視頻信息
 */
function get_vid($contentid = 0, $catid = 0, $isspecial = 0) {
 static $categorys;
 if (!$contentid) return false;
 if (!$isspecial) {
  if (!$catid) return false;
  $contentid = intval($contentid);
  $catid = intval($catid);
  $siteid = get_siteid();
  if (!$categorys) {
   $categorys = getcache(&#39;category_content_&#39;.$siteid, &#39;commons&#39;);
  }
  $modelid = $categorys[$catid][&#39;modelid&#39;];
  $video_content = app_base::load_model(&#39;video_content_model&#39;);
  $r = $video_content->get_one(array(&#39;contentid&#39;=>$contentid, &#39;modelid&#39;=>$modelid), &#39;videoid&#39;, &#39;listorder ASC&#39;);
  $video_store =app_base::load_model(&#39;video_store_model&#39;);
  return $video_store->get_one(array(&#39;videoid&#39;=>$r[&#39;videoid&#39;]));
 } else {
  $special_content = app_base::load_model(&#39;special_content_model&#39;);
  $contentid = intval($contentid);
  $video_store =app_base::load_model(&#39;video_store_model&#39;);
  $r = $special_content->get_one(array(&#39;id&#39;=>$contentid), &#39;videoid&#39;);
  return $video_store->get_one(array(&#39;videoid&#39;=>$r[&#39;videoid&#39;]));
 }
}
/**
 * Function dataformat
 * 時間轉(zhuǎn)換
 * @param $n INT時間
 */
 function dataformat($n) {
 $hours = floor($n/3600);
 $minite = floor($n%3600/60);
 $secend = floor($n%3600%60);
 $minite = $minite < 10 ? "0".$minite : $minite;
 $secend = $secend < 10 ? "0".$secend : $secend;
 if($n >= 3600){
  return $hours.":".$minite.":".$secend;
 }else{
  return $minite.":".$secend;
 }
 }
 function httpResponse($status, $msg=&#39;&#39;){
  $m = app_base::load_model(&#39;category_model&#39;);
  $CATEGORYS = $m->select(array(&#39;parentid&#39;=>0),&#39;*&#39;,&#39;&#39;,&#39;listorder&#39;);
  include CODE_PATH . &#39;libs&#39;.DIRECTORY_SEPARATOR.&#39;data&#39;.DIRECTORY_SEPARATOR.&#39;http&#39;.DIRECTORY_SEPARATOR.$status.&#39;.php&#39;;
 }
 function array_change_key_case_recursive($arr)
 {
  if(! $arr || !is_array($arr))return array();
 return array_map(function($item){
  if(is_array($item))
   $item = array_change_key_case_recursive($item);
  return $item;
 },array_change_key_case($arr));
 }
 function visitauth(){
  $vtime = time();
 $vsign = md5("cuichuande@ideadata.com.cn#$%" . $vtime);
 return "tm={$vtime}&sn={$vsign}";
 }
?>



?以上就是PHP數(shù)據(jù)的提交與過濾基本操作實(shí)例詳解?的內(nèi)容,更多相關(guān)內(nèi)容請關(guān)注PHP中文網(wǎng)(www.miracleart.cn)!

Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefa?on, veuillez contacter admin@php.cn

Outils d'IA chauds

Undress AI Tool

Undress AI Tool

Images de déshabillage gratuites

Undresser.AI Undress

Undresser.AI Undress

Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover

AI Clothes Remover

Outil d'IA en ligne pour supprimer les vêtements des photos.

Clothoff.io

Clothoff.io

Dissolvant de vêtements AI

Video Face Swap

Video Face Swap

échangez les visages dans n'importe quelle vidéo sans effort grace à notre outil d'échange de visage AI entièrement gratuit?!

Outils chauds

Bloc-notes++7.3.1

Bloc-notes++7.3.1

éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise

SublimeText3 version chinoise

Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1

Envoyer Studio 13.0.1

Puissant environnement de développement intégré PHP

Dreamweaver CS6

Dreamweaver CS6

Outils de développement Web visuel

SublimeText3 version Mac

SublimeText3 version Mac

Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds

Tutoriel PHP
1502
276
PHP appelle AI Intelligent Voice Assistant Assistant PHP Interaction System Construction PHP appelle AI Intelligent Voice Assistant Assistant PHP Interaction System Construction Jul 25, 2025 pm 08:45 PM

L'entrée vocale de l'utilisateur est capturée et envoyée au backend PHP via l'API MediaRecorder du JavaScript frontal; 2. PHP enregistre l'audio en tant que fichier temporaire et appelle STTAPI (tel que Google ou Baidu Voice Recognition) pour le convertir en texte; 3. PHP envoie le texte à un service d'IA (comme Openaigpt) pour obtenir une réponse intelligente; 4. PHP appelle ensuite TTSAPI (comme Baidu ou Google Voice Synthesis) pour convertir la réponse en fichier vocal; 5. PHP diffuse le fichier vocal vers l'avant pour jouer, terminant l'interaction. L'ensemble du processus est dominé par PHP pour assurer une connexion transparente entre toutes les liens.

Comment utiliser PHP pour créer des fonctions de partage social PHP Partage d'interface Pratique Comment utiliser PHP pour créer des fonctions de partage social PHP Partage d'interface Pratique Jul 25, 2025 pm 08:51 PM

La méthode principale de création de fonctions de partage social dans PHP est de générer dynamiquement des liens de partage qui répondent aux exigences de chaque plate-forme. 1. Obtenez d'abord la page actuelle ou les informations d'URL et d'article spécifiées; 2. Utilisez UrLencode pour coder les paramètres; 3. épisser et générer des liens de partage en fonction des protocoles de chaque plate-forme; 4. Afficher les liens sur l'avant pour que les utilisateurs puissent cliquer et partager; 5. Générez dynamiquement des balises OG sur la page pour optimiser l'affichage du contenu du partage; 6. Assurez-vous d'échapper à la saisie des utilisateurs pour empêcher les attaques XSS. Cette méthode ne nécessite pas d'authentification complexe, a de faibles co?ts de maintenance et convient à la plupart des besoins de partage de contenu.

Comment utiliser PHP combiné avec l'IA pour obtenir la correction de texte de la syntaxe PHP détection et l'optimisation Comment utiliser PHP combiné avec l'IA pour obtenir la correction de texte de la syntaxe PHP détection et l'optimisation Jul 25, 2025 pm 08:57 PM

Pour réaliser la correction d'erreur de texte et l'optimisation de la syntaxe avec l'IA, vous devez suivre les étapes suivantes: 1. Sélectionnez un modèle ou une API d'IA appropriée, tels que Baidu, Tencent API ou bibliothèque NLP open source; 2. Appelez l'API via Curl ou Guzzle de PHP et traitez les résultats de retour; 3. Afficher les informations de correction d'erreur dans l'application et permettre aux utilisateurs de choisir d'adopter l'adoption; 4. Utilisez PHP-L et PHP_CODESNIFFER pour la détection de syntaxe et l'optimisation du code; 5. Collectez en continu les commentaires et mettez à jour le modèle ou les règles pour améliorer l'effet. Lorsque vous choisissez AIAPI, concentrez-vous sur l'évaluation de la précision, de la vitesse de réponse, du prix et du support pour PHP. L'optimisation du code doit suivre les spécifications du PSR, utiliser le cache raisonnablement, éviter les requêtes circulaires, revoir le code régulièrement et utiliser x

PHP crée un système de commentaires de blog pour monétiser la revue des commentaires PHP et la stratégie anti-brosse PHP crée un système de commentaires de blog pour monétiser la revue des commentaires PHP et la stratégie anti-brosse Jul 25, 2025 pm 08:27 PM

1. La maximisation de la valeur commerciale du système de commentaires nécessite de combiner la livraison précise de la publicité native, les services à valeur ajoutée par l'utilisateur (tels que le téléchargement d'images, les commentaires de recharge), d'influencer le mécanisme d'incitation basé sur la qualité des commentaires et la conformité de la monétisation anonyme des données de données; 2. La stratégie d'audit doit adopter une combinaison de mécanismes de filtrage des mots clés dynamiques pré-audit et de signalement des utilisateurs, complétés par une note de qualité des commentaires pour réaliser une exposition hiérarchique de contenu; 3. Anti-brosses nécessite la construction d'une défense multicouche: la vérification sans capteur RecaptChav3, le robot de reconnaissance de champ de miel, IP et la limite de fréquence d'horodatage empêchent l'arrosage, et la reconnaissance du modèle de contenu marque les commentaires suspects et itéra en continu pour traiter les attaques.

Comment utiliser PHP pour combiner l'IA pour générer une image. PHP génère automatiquement des ?uvres d'art Comment utiliser PHP pour combiner l'IA pour générer une image. PHP génère automatiquement des ?uvres d'art Jul 25, 2025 pm 07:21 PM

PHP n'effectue pas directement un traitement d'image AI, mais s'intègre via les API, car il est bon dans le développement Web plut?t que dans les taches à forte intensité informatique. L'intégration de l'API peut atteindre une division professionnelle du travail, réduire les co?ts et améliorer l'efficacité; 2. Intégration des technologies clés incluez l'utilisation de Guzzle ou Curl pour envoyer des demandes HTTP, le codage et le décodage des données JSON, l'authentification de la sécurité des clés de l'API, les taches de traitement de la file d'attente asynchrones, les taches prenant du temps, la gestion des erreurs robuste et le mécanisme de retrait, le stockage et l'affichage d'images; 3. Les défis courants incluent le co?t des API incontr?lable, les résultats de génération incontr?lables, la mauvaise expérience utilisateur, les risques de sécurité et la gestion difficile des données. Les stratégies de réponse consistent à définir des quotas et des caches utilisateur, en fournissant des conseils ProTT et une sélection multi-images, des notifications asynchrones et des invites de progrès, un stockage et un audit de contenu de la variable d'environnement clé et un stockage cloud.

PHP réalise la gestion des stocks de produits de base et la monétisation de la synchronisation et du mécanisme d'alarme de l'inventaire PHP PHP réalise la gestion des stocks de produits de base et la monétisation de la synchronisation et du mécanisme d'alarme de l'inventaire PHP Jul 25, 2025 pm 08:30 PM

PHP assure l'atomicité de la déduction des stocks via les transactions de base de données et les verrous en ligne de Forupdate pour empêcher la survente élevée élevée en simultation; 2. La cohérence de l'inventaire multiplateforme dépend de la gestion centralisée et de la synchronisation axée sur les événements, combinant des notifications API / WebHook et des files d'attente de messages pour assurer une transmission fiable de données; 3. Le mécanisme d'alarme doit définir un faible inventaire, un inventaire zéro / négatif, des ventes invidables, des cycles de réapprovisionnement et des stratégies de fluctuations anormales dans différents scénarios, et sélectionner Dingtalk, SMS ou les personnes responsables par e-mail en fonction de l'urgence, et les informations d'alarme doivent être complètes et claires pour réaliser l'adaptation et la réponse rapide.

Au-delà de la pile de lampe: le r?le de PHP dans l'architecture d'entreprise moderne Au-delà de la pile de lampe: le r?le de PHP dans l'architecture d'entreprise moderne Jul 27, 2025 am 04:31 AM

PhpisstillRelevantinmodernerterpriseenvironments.1.modernPhp (7.xand8.x) offre des performances, des stricts, un jitcompilation, et modernsyntax, rendant la main

PHP Integrated AI Vorthing Reconnaissance et traducteur PHP Rendre Record Generation Solution de génération automatique PHP Integrated AI Vorthing Reconnaissance et traducteur PHP Rendre Record Generation Solution de génération automatique Jul 25, 2025 pm 07:06 PM

Sélectionnez le service de reconnaissance vocale AI approprié et intégrez PHPSDK; 2. Utilisez PHP pour appeler FFMPEG pour convertir les enregistrements en formats requis API (tels que WAV); 3. Téléchargez des fichiers sur le stockage cloud et appelez API Asynchronous Recognition; 4. Analyser les résultats JSON et organiser du texte à l'aide de la technologie NLP; 5. Générez des documents Word ou Markdown pour terminer l'automatisation des enregistrements de la réunion. L'ensemble du processus doit assurer le chiffrement des données, le contr?le d'accès et la conformité pour garantir la confidentialité et la sécurité.

See all articles