<?php
/**
 * 系统设置逻辑层
 *
 * @author Wzb
 *        
 */
class BLL_WebSet {
	/**
	 * 修改网站设置
	 *
	 * @param array $theArray
	 * @return int
	 */
	public static function edit($theArray) {
		$newArray = array ();
		$newArray = COM_OftenFunction::makeArray ( $theArray );
		$newArray ['id'] = intval ( $theArray ['theId'] );
		
		$newArray ['editorImgExt'] = BLL_WebSet::ckwords ( $newArray ['editorImgExt'] );
		$newArray ['editorLinkExt'] = BLL_WebSet::ckwords ( $newArray ['editorLinkExt'] );
		
		return DAL_WebSet::edit ( $newArray );
	}
	
	/**
	 * 获取网站设置
	 *
	 * @param int $id 默认值：1
	 * @param string $code 需要的字段 默认值：*
	 * @return array
	 */
	public static function getOne($id = 1, $code = '*') {
		return DAL_WebSet::getOne ( $id, $code );
	}
	
	/**
	 * 去除字符串中特殊后缀
	 *
	 * @param string $value
	 * @return string
	 */
	private static function ckwords($value) {
		$value = '|' . strtolower ( $value ) . '|';
		$thearray = array ("|php|","|asp|","|jsp|","|aspx|","|exe|","|js|","|dat|" );
		for($i = 0; $i < count ( $thearray ); $i ++) {
			$value = str_replace ( $thearray [$i], "||", $value );
		}
		
		if (empty ( $value )) {
			return "";
		}
		
		$temp = explode ( '|', $value );
		$value = "";
		for($i = 0; $i < count ( $temp ); $i ++) {
			if (! empty ( $temp [$i] )) {
				if (empty ( $value )) {
					$value = $temp [$i];
				} else {
					$value .= '|' . $temp [$i];
				}
			}
		}
		return $value;
	}
}
?>