Skip to content

Commit 8b13e98

Browse files
committed
Merge pull request #7 from liu21st/master
merge
2 parents 37d5ec9 + d485e0e commit 8b13e98

33 files changed

+2262
-60
lines changed

Diff for: Extend/Behavior/FireShowPageTraceBehavior.class.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// +----------------------------------------------------------------------
77
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
88
// +----------------------------------------------------------------------
9-
// | Author: luofei614 <www.3g4k.com>
9+
// | Author: luofei614 <weibo.com/luofei614>
1010
// +----------------------------------------------------------------------
1111
// $Id$
1212

@@ -18,7 +18,7 @@
1818
* 定义项目的tags.php文件,
1919
* <code>
2020
* <?php return array(
21-
* 'view_end'=>array(
21+
* 'app_end'=>array(
2222
* 'FireShowPageTrace'
2323
* )
2424
* );
@@ -2090,4 +2090,4 @@ public function setRendererUrl($URL)
20902090
{
20912091
trigger_error("The FirePHP::setRendererUrl() method is no longer supported", E_USER_DEPRECATED);
20922092
}
2093-
}
2093+
}

Diff for: Extend/Driver/Db/DbPdo.class.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function getFields($tableName) {
272272
'type' => $val['type'],
273273
'notnull' => (bool)(((isset($val['null'])) && ($val['null'] === '')) || ((isset($val['notnull'])) && ($val['notnull'] === ''))), // not null is empty, null is yes
274274
'default' => isset($val['default'])? $val['default'] :(isset($val['dflt_value'])?$val['dflt_value']:""),
275-
'primary' => isset($val['dey'])?strtolower($val['dey']) == 'pri':(isset($val['pk'])?$val['pk']:false),
275+
'primary' => isset($val['key'])?strtolower($val['key']) == 'pri':(isset($val['pk'])?$val['pk']:false),
276276
'autoinc' => isset($val['extra'])?strtolower($val['extra']) == 'auto_increment':(isset($val['key'])?$val['key']:false),
277277
);
278278
}
@@ -287,7 +287,7 @@ public function getFields($tableName) {
287287
public function getTables($dbName='') {
288288
if(C('DB_FETCH_TABLES_SQL')) {
289289
// 定义特殊的表查询SQL
290-
$sql = str_replace('%db%',$dnName,C('DB_FETCH_TABLES_SQL'));
290+
$sql = str_replace('%db%',$dbName,C('DB_FETCH_TABLES_SQL'));
291291
}else{
292292
switch($this->dbType) {
293293
case 'ORACLE':

Diff for: Extend/Engine/Cluster/DefaultApp/IO/auto.php

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
if(is_file(APP_PATH.'Common/common_local.php')){
2020
require APP_PATH.'Common/common_local.php';
2121
}
22+
function file_domain($domain=''){
23+
return __ROOT__.'/'.$domain;
24+
}
2225
//本地上传文件的IO操作
2326
function file_upload($src_file,$dest_file){
2427
$pdir=dirname($dest_file);

Diff for: Extend/Engine/Cluster/DefaultApp/Lib/ORG/UploadFile.class.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ private function save($file) {
107107
if(!empty($this->water)){
108108
import($this->imageClassPath);
109109
$tmp_water=tempnam(sys_get_temp_dir(),'tp_');
110-
Image::water($file['tmp_name'],$this->water,$tmp_water,$this->water_alpha,false);
111-
if($this->water_savename){
112-
file_upload($tmp_water,$this->water_savename);
113-
}else{
114-
$uploadfile=$tmp_water;
115-
}
110+
$ret=Image::water($file['tmp_name'],$this->water,$tmp_water,$this->water_alpha,false);
111+
if(false!==$ret){
112+
if($this->water_savename){
113+
file_upload($tmp_water,$this->water_savename);
114+
}else{
115+
$uploadfile=$tmp_water;
116+
}
117+
}
116118
}
117119
//[cluster] 上传文件
118120
if(!$this->thumbRemoveOrigin && !file_upload($uploadfile, $this->autoCharset($filename,'utf-8','gbk'))) {

Diff for: Extend/Engine/Sae/Lib/Core/SaeMC.class.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static public function file_exists($filename) {
9191

9292
static function error() {
9393
$error = error_get_last();
94-
if (!is_null($error) && strpos($error['file'], 'eval()') !== false) {
94+
if (!is_null($error) && strpos($error['file'], 'eval()') && ($error['type'] & error_reporting()) !== false) {
9595
if(!class_exists('Think')){
9696
ob_end_clean();
9797
if(C('OUTPUT_ENCODE')){
@@ -117,4 +117,4 @@ static function error() {
117117
}
118118
}
119119

120-
}
120+
}

Diff for: Extend/Engine/Sae/Lib/Driver/Db/DbMysql.class.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function connect($config='',$linkNum=0,$force=false) {
5151
// 是否长连接
5252
$pconnect = !empty($config['params']['persist'])? $config['params']['persist']:$this->pconnect;
5353
if($pconnect) {
54-
$this->linkID[$linkNum] = mysql_pconnect( $host, $config['username'], $config['password'],CLIENT_MULTI_RESULTS);
54+
$this->linkID[$linkNum] = mysql_pconnect( $host, $config['username'], $config['password'],131072);
5555
}else{
56-
$this->linkID[$linkNum] = mysql_connect( $host, $config['username'], $config['password'],true,CLIENT_MULTI_RESULTS);
56+
$this->linkID[$linkNum] = mysql_connect( $host, $config['username'], $config['password'],true,131072);
5757
}
5858
if ( !$this->linkID[$linkNum] || (!empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) || C('SPARE_DB_DEBUG') ) {
5959
$errStr=mysql_error();
@@ -62,7 +62,7 @@ public function connect($config='',$linkNum=0,$force=false) {
6262
if(C('SMS_ALERT_ON')) Sms::send('mysql超额被禁用,请在SAE日志中心查看详情', $errStr,Sms::MYSQL_ERROR);
6363
//[sae]启动备用数据库
6464
if(C('SPARE_DB_HOST')){
65-
$this->linkID[$linkNum]=mysql_connect( C('SPARE_DB_HOST').(C('SPARE_DB_PORT')?':'.C('SPARE_DB_PORT'):''), C('SPARE_DB_USER'), C('SPARE_DB_PWD'),true,CLIENT_MULTI_RESULTS);
65+
$this->linkID[$linkNum]=mysql_connect( C('SPARE_DB_HOST').(C('SPARE_DB_PORT')?':'.C('SPARE_DB_PORT'):''), C('SPARE_DB_USER'), C('SPARE_DB_PWD'),true,131072);
6666
if(!$this->linkID[$linkNum]){
6767
throw_exception('备用数据库连接失败');
6868
}

Diff for: Extend/Library/ORG/Crypt/Rsa.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function pow_mod($p, $q, $r) {
8888

8989
$idx++;
9090
}
91-
array_pus($partial_results, $part_res);
91+
array_push($partial_results, $part_res);
9292
}
9393
// Calculate final result
9494
$result = "1";

Diff for: Extend/Library/ORG/Net/UploadFile.class.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class UploadFile {//类定义开始
3333
'thumbFile' => '',// 缩略图文件名
3434
'thumbExt' => '',// 缩略图扩展名
3535
'thumbRemoveOrigin' => false,// 是否移除原图
36+
'thumbType' => 1, // 缩略图生成方式 1 按设置大小截取 0 按原图等比例缩略
3637
'zipImages' => false,// 压缩图片文件上传
3738
'autoSub' => false,// 启用子目录保存文件
3839
'subType' => 'hash',// 子目录创建方式 可以使用hash date custom
@@ -126,7 +127,12 @@ private function save($file) {
126127
$suffix = isset($thumbSuffix[$i])?$thumbSuffix[$i]:$thumbSuffix[0];
127128
$thumbname = $prefix.basename($filename,'.'.$file['extension']).$suffix;
128129
}
129-
Image::thumb($filename,$thumbPath.$thumbname.'.'.$thumbExt,'',$thumbWidth[$i],$thumbHeight[$i],true);
130+
if(1 == $this->thumbType){
131+
Image::thumb2($filename,$thumbPath.$thumbname.'.'.$thumbExt,'',$thumbWidth[$i],$thumbHeight[$i],true);
132+
}else{
133+
Image::thumb($filename,$thumbPath.$thumbname.'.'.$thumbExt,'',$thumbWidth[$i],$thumbHeight[$i],true);
134+
}
135+
130136
}
131137
if($this->thumbRemoveOrigin) {
132138
// 生成缩略图之后删除原图

Diff for: Extend/Library/ORG/Util/Authority.class.php renamed to Extend/Library/ORG/Util/Auth.class.php

+41-37
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
// +----------------------------------------------------------------------
77
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
88
// +----------------------------------------------------------------------
9-
// | Author: luofei614 <www.3g4k.com> 
9+
// | Author: luofei614 <weibo.com/luofei614> 
1010
// +----------------------------------------------------------------------
11-
// $Id: Authority.class.php 2504 2011-12-28 07:35:29Z liu21st $
1211
/**
1312
* 权限认证类
1413
* 功能特性:
1514
* 1,是对规则进行认证,不是对节点进行认证。用户可以把节点当作规则名称实现对节点进行认证。
16-
* $auth=new Authority(); $auth->getAuth('规则名称','用户id')
15+
* $auth=new Auth(); $auth->check('规则名称','用户id')
1716
* 2,可以同时对多条规则进行认证,并设置多条规则的关系(or或者and)
18-
* $auth=new Authority(); $auth->getAuth('规则1,规则2','用户id','and')
17+
* $auth=new Auth(); $auth->check('规则1,规则2','用户id','and')
1918
* 第三个参数为and时表示,用户需要同时具有规则1和规则2的权限。 当第三个参数为or时,表示用户值需要具备其中一个条件即可。默认为or
2019
* 3,一个用户可以属于多个用户组(think_auth_group_access表 定义了用户所属用户组)。我们需要设置每个用户组拥有哪些规则(think_auth_group 定义了用户组权限)
2120
*
@@ -24,51 +23,52 @@
2423
* @category ORG
2524
* @package ORG
2625
* @subpackage Util
27-
* @author luofei614<www.3g4k.com>
26+
* @author luofei614<weibo.com/luofei614>
2827
*/
2928

3029
//数据库
3130
/*
3231
-- ----------------------------
3332
-- think_auth_rule,规则表,
34-
-- id:主键,name:规则唯一标识, title:规则中文名称 type:类型(0存在规则就通过,1按规则表达时进行认证),condition:规则表达式
33+
-- id:主键,name:规则唯一标识, title:规则中文名称 status 状态:为1正常,为0禁用,condition:规则表达式,为空表示存在就验证,不为空表示按照条件验证
3534
-- ----------------------------
3635
DROP TABLE IF EXISTS `think_auth_rule`;
37-
CREATE TABLE `think_auth_rule` (
38-
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
39-
`name` char(10) NOT NULL DEFAULT '',
40-
`title` char(20) NOT NULL DEFAULT '',
41-
`type` tinyint(1) NOT NULL DEFAULT '0',
42-
`condition` char(100) NOT NULL DEFAULT '',
43-
PRIMARY KEY (`id`)
44-
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
36+
CREATE TABLE `think_auth_rule` (
37+
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
38+
`name` char(80) NOT NULL DEFAULT '',
39+
`title` char(20) NOT NULL DEFAULT '',
40+
`status` tinyint(1) NOT NULL DEFAULT '1',
41+
`condition` char(100) NOT NULL DEFAULT '',
42+
PRIMARY KEY (`id`),
43+
UNIQUE KEY `name` (`name`)
44+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
4545
-- ----------------------------
4646
-- think_auth_group 用户组表,
47-
-- id:主键, title:用户组中文名称, rules:用户组拥有的规则id, 多个规则用“,”隔开
47+
-- id:主键, title:用户组中文名称, rules:用户组拥有的规则id, 多个规则","隔开,status 状态:为1正常,为0禁用
4848
-- ----------------------------
4949
DROP TABLE IF EXISTS `think_auth_group`;
50-
CREATE TABLE `think_auth_group` (
51-
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
52-
`title` char(100) NOT NULL DEFAULT '',
53-
`rules` char(80) NOT NULL DEFAULT '',
54-
PRIMARY KEY (`id`)
55-
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
50+
CREATE TABLE `think_auth_group` (
51+
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
52+
`title` char(100) NOT NULL DEFAULT '',
53+
`status` tinyint(1) NOT NULL DEFAULT '1',
54+
`rules` char(80) NOT NULL DEFAULT '',
55+
PRIMARY KEY (`id`)
56+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
5657
-- ----------------------------
5758
-- think_auth_group_access 用户组明细表
5859
-- uid:用户id,group_id:用户组id
5960
-- ----------------------------
6061
DROP TABLE IF EXISTS `think_auth_group_access`;
61-
CREATE TABLE `think_auth_group_access` (
62-
`uid` mediumint(8) unsigned NOT NULL,
63-
`group_id` mediumint(8) unsigned NOT NULL,
64-
UNIQUE KEY `uid_2` (`uid`,`group_id`),
65-
KEY `uid` (`uid`),
66-
KEY `group_id` (`group_id`)
62+
CREATE TABLE `think_auth_group_access` (
63+
`uid` mediumint(8) unsigned NOT NULL,
64+
`group_id` mediumint(8) unsigned NOT NULL,
65+
UNIQUE KEY `uid_group_id` (`uid`,`group_id`),
66+
KEY `uid` (`uid`),
67+
KEY `group_id` (`group_id`)
6768
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
68-
6969
*/
7070

71-
class Authority {
71+
class Auth{
7272

7373
//默认配置
7474
protected $_config = array(
@@ -88,7 +88,7 @@ public function __construct() {
8888
}
8989

9090
//获得权限$name 可以是字符串或数组或逗号分割, uid为 认证的用户id, $or 是否为or关系,为true是, name为数组,只要数组中有一个条件通过则通过,如果为false需要全部条件通过。
91-
public function getAuth($name, $uid, $relation='or') {
91+
public function check($name, $uid, $relation='or') {
9292
if (!$this->_config['AUTH_ON'])
9393
return true;
9494
$authList = $this->getAuthList($uid);
@@ -117,9 +117,10 @@ public function getAuth($name, $uid, $relation='or') {
117117
//获得用户组,外部也可以调用
118118
public function getGroups($uid) {
119119
static $groups = array();
120-
if (!empty($groups[$uid]))
120+
if (isset($groups[$uid]))
121121
return $groups[$uid];
122-
$groups[$uid] = M()->table($this->_config['AUTH_GROUP_ACCESS'] . ' a')->where("a.uid='$uid'")->join($this->_config['AUTH_GROUP']." g on a.group_id=g.id")->select();
122+
$user_groups = M()->table($this->_config['AUTH_GROUP_ACCESS'] . ' a')->where("a.uid='$uid' and g.status='1'")->join($this->_config['AUTH_GROUP']." g on a.group_id=g.id")->select();
123+
$groups[$uid]=$user_groups?$user_groups:array();
123124
return $groups[$uid];
124125
}
125126

@@ -143,16 +144,19 @@ protected function getAuthList($uid) {
143144
$_authList[$uid] = array();
144145
return array();
145146
}
146-
//读取用户组所有权限规则(in)
147-
$map['id'] = array('in', $ids);
147+
//读取用户组所有权限规则
148+
$map=array(
149+
'id'=>array('in',$ids),
150+
'status'=>1
151+
);
148152
$rules = M()->table($this->_config['AUTH_RULE'])->where($map)->select();
149153
//循环规则,判断结果。
150154
$authList = array();
151155
foreach ($rules as $r) {
152-
if ($r['type'] == 1) {
156+
if (!empty($r['condition'])) {
153157
//条件验证
154158
$user = $this->getUserInfo($uid);
155-
$command = preg_replace('/\{(\w*?)\}/e', '$user[\'\\1\']', $r['condition']);
159+
$command = preg_replace('/\{(\w*?)\}/', '$user[\'\\1\']', $r['condition']);
156160
//dump($command);//debug
157161
@(eval('$condition=(' . $command . ');'));
158162
if ($condition) {
@@ -179,4 +183,4 @@ protected function getUserInfo($uid) {
179183
return $userinfo[$uid];
180184
}
181185

182-
}
186+
}

Diff for: Extend/Library/ORG/Util/Image.class.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,18 @@ static function thumb($image, $thumbname, $type='', $maxWidth=200, $maxHeight=50
226226
}
227227
return false;
228228
}
229+
229230
/**
230-
+----------------------------------------------------------
231231
* 生成特定尺寸缩略图 解决原版缩略图不能满足特定尺寸的问题 PS:会裁掉图片不符合缩略图比例的部分
232-
+----------------------------------------------------------
233232
* @static
234233
* @access public
235-
+----------------------------------------------------------
236234
* @param string $image 原图
237235
* @param string $type 图像格式
238236
* @param string $thumbname 缩略图文件名
239237
* @param string $maxWidth 宽度
240238
* @param string $maxHeight 高度
241239
* @param boolean $interlace 启用隔行扫描
242-
+----------------------------------------------------------
243240
* @return void
244-
+----------------------------------------------------------
245241
*/
246242
static function thumb2($image, $thumbname, $type='', $maxWidth=200, $maxHeight=50, $interlace=true) {
247243
// 获取原图信息
@@ -304,6 +300,7 @@ static function thumb2($image, $thumbname, $type='', $maxWidth=200, $maxHeight=5
304300
}
305301
return false;
306302
}
303+
307304
/**
308305
* 根据给定的字符串生成图像
309306
* @static

Diff for: Extend/Model/AdvModel.class.php

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class AdvModel extends Model {
2525
protected $serializeField = array();
2626
protected $readonlyField = array();
2727
protected $_filter = array();
28+
protected $partition = array();
2829

2930
public function __construct($name='',$tablePrefix='',$connection='') {
3031
if('' !== $name || is_subclass_of($this,'AdvModel') ){

Diff for: Extend/Tool/TPM/SwitchMobileTplBehavior.class.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
class SwitchMobileTplBehavior extends Behavior {
3+
//智能切换模板引擎
4+
public function run(&$params){
5+
if(APP_DEBUG){
6+
header('Access-Control-Allow-Origin:*');
7+
header('Access-Control-Allow-Headers:client,x-requested-with');
8+
}
9+
if(isset($_SERVER['HTTP_CLIENT']) &&'PhoneClient'==$_SERVER['HTTP_CLIENT']){
10+
C('TMPL_ENGINE_TYPE','Mobile');
11+
define('IS_CLIENT',true);
12+
}else{
13+
define('IS_CLIENT',false);
14+
if('./client/'==TMPL_PATH){
15+
$find=APP_TMPL_PATH;
16+
$replace=__ROOT__.'/client/';
17+
$parse_string=C('TMPL_PARSE_STRING');
18+
if(is_null($parse_string)) $parse_string=array();
19+
//自动增加一个模板替换变量,用于修复SAE平台下模板中使用../Public 会解析错误的问题。
20+
C('TMPL_PARSE_STRING',array_merge($parse_string,array($find=>$replace)));
21+
//判断如果是云窗调试器访问跳转访问首页到client目录
22+
if(APP_DEBUG && ''==__INFO__ && preg_match('/android|iphone/i',$_SERVER['HTTP_USER_AGENT'])){
23+
redirect(__ROOT__.'/client');
24+
exit();
25+
}
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)