Skip to content
12 changes: 7 additions & 5 deletions Extend/Action/RestAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ public function __call($method,$args) {
throw_exception(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_'));
}
if(isset($input[$args[0]])) { // 取值操作
$data = $input[$args[0]];
$fun = $args[1]?$args[1]:C('DEFAULT_FILTER');
$data = $fun($data); // 参数过滤
$data = $input[$args[0]];
$fun = $args[1]?$args[1]:C('DEFAULT_FILTER');
$ref_func = new ReflectionFunction($fun);
$data = $ref_func->invoke($data); // 参数过滤
//$data = $fun($data);
}else{ // 变量默认值
$data = isset($args[2])?$args[2]:NULL;
}
Expand Down Expand Up @@ -213,7 +215,7 @@ protected function response($data,$type='',$code=200) {
* @access protected
* @param mixed $data 要返回的数据
* @param String $type 返回类型 JSON XML
* @return void
* @return string
*/
protected function encodeData($data,$type='') {
if(empty($data)) return '';
Expand Down Expand Up @@ -312,7 +314,7 @@ protected function getAcceptType(){

foreach($type as $key=>$val){
$array = explode(',',$val);
foreach($array as $k=>$v){
foreach($array as $v){
if(stristr($_SERVER['HTTP_ACCEPT'], $v)) {
return $key;
}
Expand Down
3 changes: 1 addition & 2 deletions Extend/Behavior/AgentCheckBehavior.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ public function run(&$params) {
exit('Access Denied');
}
}
}
?>
}
4 changes: 2 additions & 2 deletions Extend/Driver/Cache/CacheApachenote.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function get($name) {
* @access public
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @return boolen
* @return bool
*/
public function set($name, $value) {
N('cache_write',1);
Expand All @@ -93,7 +93,7 @@ public function set($name, $value) {
* 删除缓存
* @access public
* @param string $name 缓存变量名
* @return boolen
* @return bool
*/
public function rm($name) {
$this->open();
Expand Down
6 changes: 3 additions & 3 deletions Extend/Driver/Cache/CacheApc.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function get($name) {
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param integer $expire 有效时间(秒)
* @return boolen
* @return bool
*/
public function set($name, $value, $expire = null) {
N('cache_write',1);
Expand All @@ -71,7 +71,7 @@ public function set($name, $value, $expire = null) {
* 删除缓存
* @access public
* @param string $name 缓存变量名
* @return boolen
* @return bool
*/
public function rm($name) {
return apc_delete($this->options['prefix'].$name);
Expand All @@ -80,7 +80,7 @@ public function rm($name) {
/**
* 清除缓存
* @access public
* @return boolen
* @return bool
*/
public function clear() {
return apc_clear_cache();
Expand Down
6 changes: 3 additions & 3 deletions Extend/Driver/Cache/CacheDb.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function get($name) {
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param integer $expire 有效时间(秒)
* @return boolen
* @return bool
*/
public function set($name, $value,$expire=null) {
$data = serialize($value);
Expand Down Expand Up @@ -123,7 +123,7 @@ public function set($name, $value,$expire=null) {
* 删除缓存
* @access public
* @param string $name 缓存变量名
* @return boolen
* @return bool
*/
public function rm($name) {
$name = $this->options['prefix'].addslashes($name);
Expand All @@ -133,7 +133,7 @@ public function rm($name) {
/**
* 清除缓存
* @access public
* @return boolen
* @return bool
*/
public function clear() {
return $this->handler->execute('TRUNCATE TABLE `'.$this->options['table'].'`');
Expand Down
4 changes: 2 additions & 2 deletions Extend/Driver/Cache/CacheEaccelerator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function get($name) {
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param integer $expire 有效时间(秒)
* @return boolen
* @return bool
*/
public function set($name, $value, $expire = null) {
N('cache_write',1);
Expand All @@ -71,7 +71,7 @@ public function set($name, $value, $expire = null) {
* 删除缓存
* @access public
* @param string $name 缓存变量名
* @return boolen
* @return bool
*/
public function rm($name) {
return eaccelerator_rm($this->options['prefix'].$name);
Expand Down
9 changes: 5 additions & 4 deletions Extend/Driver/Cache/CacheMemcache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function __construct($options=array()) {
$this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX');
$this->options['length'] = isset($options['length'])? $options['length'] : 0;
$func = $options['persistent'] ? 'pconnect' : 'connect';
$this->handler = new Memcache;
$this->handler = new Memcache();
$options['timeout'] === false ?
$this->handler->$func($options['host'], $options['port']) :
$this->handler->$func($options['host'], $options['port'], $options['timeout']);
Expand All @@ -64,7 +64,7 @@ public function get($name) {
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param integer $expire 有效时间(秒)
* @return boolen
* @return bool
*/
public function set($name, $value, $expire = null) {
N('cache_write',1);
Expand All @@ -86,7 +86,8 @@ public function set($name, $value, $expire = null) {
* 删除缓存
* @access public
* @param string $name 缓存变量名
* @return boolen
* @param bool $ttl 缓存生存期 单位:秒
* @return bool
*/
public function rm($name, $ttl = false) {
$name = $this->options['prefix'].$name;
Expand All @@ -98,7 +99,7 @@ public function rm($name, $ttl = false) {
/**
* 清除缓存
* @access public
* @return boolen
* @return bool
*/
public function clear() {
return $this->handler->flush();
Expand Down
12 changes: 7 additions & 5 deletions Extend/Driver/Cache/CacheRedis.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct($options=array()) {
$this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX');
$this->options['length'] = isset($options['length'])? $options['length'] : 0;
$func = $options['persistent'] ? 'pconnect' : 'connect';
$this->handler = new Redis;
$this->handler = new Redis();
$options['timeout'] === false ?
$this->handler->$func($options['host'], $options['port']) :
$this->handler->$func($options['host'], $options['port'], $options['timeout']);
Expand All @@ -67,7 +67,7 @@ public function get($name) {
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param integer $expire 有效时间(秒)
* @return boolen
* @return bool
*/
public function set($name, $value, $expire = null) {
N('cache_write',1);
Expand All @@ -93,16 +93,18 @@ public function set($name, $value, $expire = null) {
* 删除缓存
* @access public
* @param string $name 缓存变量名
* @return boolen
* @return bool
*/
public function rm($name) {
return $this->handler->delete($this->options['prefix'].$name);
//Redis::delete方法返回删除的数量,而不是布尔值
$num = $this->handler->delete($this->options['prefix'].$name);
return $num > 0;
}

/**
* 清除缓存
* @access public
* @return boolen
* @return bool
*/
public function clear() {
return $this->handler->flushDB();
Expand Down
2 changes: 1 addition & 1 deletion Extend/Driver/Db/DbMongo.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function connect($config='',$linkNum=0) {
if(empty($config)) $config = $this->config;
$host = 'mongodb://'.($config['username']?"{$config['username']}":'').($config['password']?":{$config['password']}@":'').$config['hostname'].($config['hostport']?":{$config['hostport']}":'').'/'.($config['database']?"{$config['database']}":'');
try{
$this->linkID[$linkNum] = new mongoClient( $host,$config['params']);
$this->linkID[$linkNum] = new MongoClient( $host,$config['params']);
}catch (MongoConnectionException $e){
throw_exception($e->getmessage());
}
Expand Down
63 changes: 35 additions & 28 deletions Extend/Function/extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

/**
* 字符串截取,支持中文和其他编码
* @static
* @access public
* @param string $str 需要转换的字符串
* @param string $start 开始位置
* @param string $length 截取长度
* @param int $start 开始位置
* @param int $length 截取长度
* @param string $charset 编码格式
* @param string $suffix 截断显示字符
* @param bool $suffix 截断显示字符
* @return string
*/
function msubstr($str, $start=0, $length, $charset="utf-8", $suffix=true) {
Expand All @@ -49,9 +47,8 @@ function msubstr($str, $start=0, $length, $charset="utf-8", $suffix=true) {

/**
* 产生随机字串,可用来自动生成密码 默认长度6位 字母和数字混合
* @param string $len 长度
* @param string $type 字串类型
* 0 字母 1 数字 其它 混合
* @param int $len 长度
* @param string $type 字串类型:0 字母 1 数字 其它 混合
* @param string $addChars 额外字符
* @return string
*/
Expand Down Expand Up @@ -95,7 +92,8 @@ function rand_string($len=6,$type='',$addChars='') {

/**
* 获取登录验证码 默认为4位数字
* @param string $fmode 文件名
* @param int $length
* @param int $mode 字串类型:0 字母 1 数字 其它 混合
* @return string
*/
function build_verify ($length=4,$mode=1) {
Expand All @@ -104,6 +102,8 @@ function build_verify ($length=4,$mode=1) {

/**
* 字节格式化 把字节数格式为 B K M G T 描述的大小
* @param int $size
* @param int $dec
* @return string
*/
function byte_format($size, $dec=2) {
Expand All @@ -122,16 +122,22 @@ function byte_format($size, $dec=2) {
* @return Boolean
*/
function is_utf8($string) {
return preg_match('%^(?:
[\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', $string);
if (function_exists('mb_check_encoding')) {
$flag = mb_check_encoding($string, 'UTF-8');
}
else {
$flag = preg_match('%^(?:
[\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', $string);
}
return $flag;
}
/**
* 代码加亮
Expand Down Expand Up @@ -362,10 +368,11 @@ function remove_xss($val) {

/**
* 把返回的数据集转换成Tree
* @access public
* @param array $list 要转换的数据集
* @param string $pk 列表主键
* @param string $pid parent标记字段
* @param string $level level标记字段
* @param string $child Tree中子元素所在key
* @param int $root 根元素pid值
* @return array
*/
function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0) {
Expand Down Expand Up @@ -395,19 +402,18 @@ function list_to_tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0) {

/**
* 对查询结果集进行排序
* @access public
* @param array $list 查询结果
* @param string $field 排序的字段名
* @param array $sortby 排序类型
* asc正向排序 desc逆向排序 nat自然排序
* @param string $sort_by asc正向排序 desc逆向排序 nat自然排序
* @return array
*/
function list_sort_by($list,$field, $sortby='asc') {
function list_sort_by($list,$field, $sort_by='asc') {
if(is_array($list)){
$refer = $resultSet = array();
foreach ($list as $i => $data)
$refer[$i] = &$data[$field];
switch ($sortby) {
$sort_by = strtolower($sort_by);
switch ($sort_by) {
case 'asc': // 正向排序
asort($refer);
break;
Expand Down Expand Up @@ -541,10 +547,11 @@ function addItem($path,&$zip,&$base_dir){
* @param string $hedef 解压到的路径
*/
function ezip($zip, $hedef = ''){
$dirname=preg_replace('/.zip/', '', $zip);
//$dirname=preg_replace('/.zip/', '', $zip);
$dirname = dirname($zip);
$root = $_SERVER['DOCUMENT_ROOT'].'/zip/';
$zip = zip_open($root . $zip);
@mkdir($root . $hedef . $dirname.'/'.$zip_dosya);
@mkdir($root . $hedef . $dirname.'/');
while($zip_icerik = zip_read($zip)){
$zip_dosya = zip_entry_name($zip_icerik);
if(strpos($zip_dosya, '.')){
Expand Down
8 changes: 7 additions & 1 deletion Extend/Library/ORG/Util/Auth.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ protected function getAuthList($uid) {
$user = $this->getUserInfo($uid);
$command = preg_replace('/\{(\w*?)\}/', '$user[\'\\1\']', $r['condition']);
//dump($command);//debug
@(eval('$condition=(' . $command . ');'));
//@(eval('$condition=(' . $command . ');'));
if (defined($command)) {
$condition = $command;
}
else {
$condition = strval($command);
}
if ($condition) {
$authList[] = $r['name'];
}
Expand Down