Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
system
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
_site-res
system
Commits
e3eefdf3
Commit
e3eefdf3
authored
May 08, 2018
by
tufengqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持版本控制
parent
81132f60
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
209 additions
and
8 deletions
+209
-8
ResponseApi.php
classes/fpf/response/ResponseApi.php
+10
-8
Application.php
classes/fpf/yii_component/Application.php
+30
-0
CookieEdit.php
classes/fpf/yii_component/views/CookieEdit.php
+164
-0
ip.php
config/ip.php
+5
-0
No files found.
classes/fpf/response/ResponseApi.php
View file @
e3eefdf3
...
...
@@ -3,6 +3,7 @@ namespace fpf\response;
use
fpf\response\BaseConstant
;
use
yii\helpers\Html
;
use
yii\web\Response
;
trait
ResponseApi
{
...
...
@@ -77,7 +78,7 @@ trait ResponseApi
{
$callback
=
''
;
if
(
true
===
self
::
$is_support_jsonp
)
{
self
::
header
(
'Content-type
:
application/javascript'
);
self
::
header
(
'Content-type
'
,
'
application/javascript'
);
$callback_key
=
'jsonpcallback'
;
$callback
=
$_GET
[
$callback_key
];
if
(
$callback
)
{
...
...
@@ -86,7 +87,7 @@ trait ResponseApi
}
}
if
(
!
$callback
)
{
self
::
header
(
'Content-type
:
application/json'
);
self
::
header
(
'Content-type
'
,
'
application/json'
);
}
echo
$json
;
if
(
BaseConstant
::
FINALTAG
===
$flag
)
{
...
...
@@ -106,10 +107,10 @@ trait ResponseApi
}
if
(
$callback
)
{
$callback
=
Html
::
encode
(
$callback_key
);
self
::
header
(
'Content-type
:
application/javascript'
);
self
::
header
(
'Content-type
'
,
'
application/javascript'
);
echo
$callback
.
'('
.
$json_str
.
')'
;
}
else
{
self
::
header
(
'Content-type
:
application/json'
);
self
::
header
(
'Content-type
'
,
'
application/json'
);
echo
$json_str
;
}
}
...
...
@@ -125,18 +126,19 @@ trait ResponseApi
}
if
(
$callback
)
{
$callback
=
Html
::
encode
(
$callback_key
);
self
::
header
(
'Content-type
:
application/javascript'
);
self
::
header
(
'Content-type
'
,
'
application/javascript'
);
echo
$callback
.
'('
.
json_encode
(
$arr
)
.
')'
;
}
else
{
self
::
header
(
'Content-type
:
application/json'
);
self
::
header
(
'Content-type
'
,
'
application/json'
);
echo
json_encode
(
$arr
);
}
}
public
function
header
(
$value
)
public
static
function
header
(
$key
,
$value
)
{
if
(
1
!=
\Yii
::
$app
->
request
->
get
(
'debug'
))
{
header
(
$value
);
\Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_RAW
;
\Yii
::
$app
->
response
->
headers
->
add
(
$key
,
$value
);
}
}
}
classes/fpf/yii_component/Application.php
View file @
e3eefdf3
...
...
@@ -12,6 +12,7 @@ class Application extends Component
public
$terry
;
private
$configures
=
[];
private
$debug_config
=
[];
const
APP_SELF_CONFIG_PREFIX
=
'appself_'
;
public
function
__construct
(
$config
=
[])
{
$this
->
trace_config
=
isset
(
$_GET
[
"__config"
]);
...
...
@@ -83,5 +84,34 @@ class Application extends Component
}
return
$config
;
}
/**
* 编辑各个项目的cookie信息
*/
public
function
cookieEdit
(
$ob_content
)
{
$set_cookie_val
=
Yii
::
$app
->
request
->
get
(
'set_cookie_val'
,
''
);
if
(
$set_cookie_val
)
{
$cookies
=
Yii
::
$app
->
response
->
cookies
;
setcookie
(
VERSION_KEY
,
$set_cookie_val
,
time
()
+
3600
*
24
*
7
);
header
(
'Content-type: application/javascript;charset=utf-8'
);
return
;
}
$app_self_config
=
Yii
::
$app
->
fpf
->
getConfig
(
self
::
APP_SELF_CONFIG_PREFIX
.
APP_NAME
,
'common'
);
$user_ip
=
Yii
::
$app
->
request
->
userIP
;
if
(
$this
->
isAllowIp
(
$user_ip
))
{
// 开关开启,用户IP是公司IP,内外IP,允许打开cookie编辑
include
(
__DIR__
.
'/views/CookieEdit.php'
);
}
}
private
function
isAllowIp
(
$user_ip
)
{
$company_ip_list
=
Yii
::
$app
->
fpf
->
getConfig
(
'company_ip_list'
,
'ip'
);
if
((
in_array
(
$user_ip
,
$company_ip_list
)
||
!
filter_var
(
$user_ip
,
FILTER_VALIDATE_IP
,
FILTER_FLAG_NO_PRIV_RANGE
)
||
'127.0.0.1'
===
$user_ip
))
{
return
true
;
}
return
false
;
}
}
classes/fpf/yii_component/views/CookieEdit.php
0 → 100644
View file @
e3eefdf3
<?php
header
(
'Content-type: text/html'
);
?>
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
COOKIE 编辑插件
</title>
<style>
body
{
font-family
:
微软雅黑
;}
.app_print
{
color
:
#666666
;}
.content
{
width
:
1024px
;
margin
:
0
auto
;
color
:
#333333
;
word-wrap
:
break-word
;
word-break
:
break-all
;
}
/* ========= table表格 ==========={{{ */
table
.dataintable
{
border
:
1px
solid
#aaa
;
border-collapse
:
collapse
;
margin-top
:
10px
;
width
:
100%
;
}
table
.dataintable
th
{
background-color
:
#d5d5d5
;
border
:
1px
solid
#aaa
;
padding
:
5px
15px
5px
6px
;
text-align
:
left
;
vertical-align
:
baseline
;
}
table
.dataintable
td
{
background-color
:
#efefef
;
border
:
1px
solid
#aaa
;
padding
:
6px
15px
6px
6px
;
vertical-align
:
text-top
;
}
table
.fashiontable
{
border-collapse
:
collapse
;
border-spacing
:
0
;
border-top
:
2px
solid
#e2e2e2
;
width
:
100%
;
}
table
.fashiontable
th
{
background
:
#f2f2f2
none
repeat
scroll
0
0
;
border-bottom
:
1px
solid
#e2e2e2
;
color
:
#6a6a6a
;
height
:
34px
;
text-align
:
center
;
}
table
.fashiontable
td
{
border-bottom
:
1px
solid
#e2e2e2
;
color
:
#999
;
height
:
26px
;
padding
:
12px
0
;
}
table
.fashiontable
tr
:hover
{
background
:
#f5f5f5
;
}
/* ========= table表格 ===========}}} */
.cookie_table
.dataintable
th
{
height
:
40px
;
line-height
:
40px
;}
.cookie_table
.dataintable
td
,
.cookie_table
.dataintable
th
{
text-align
:
center
;
padding
:
10px
;
color
:
#666666
;}
.cookie_table
td
input
{
height
:
30px
;
width
:
460px
;
padding
:
0
10px
;
border
:
1px
solid
#d6d6d6
;}
.cookie_table
tr
{
padding
:
10px
;}
.btn_list
{
overflow
:
hidden
;
padding
:
5px
;}
.btn_list
span
{
padding
:
2px
10px
;
background
:
#dddddd
;
cursor
:
pointer
;
color
:
#666666
;
border
:
1px
solid
#999999
;}
.notice_box
{
height
:
30px
;
display
:
none
;
line-height
:
30px
;
background
:
#fefcee
;
border
:
1px
solid
#f3d995
;
color
:
#df9c1f
;
text-align
:
center
;
}
</style>
<script
src=
"https://www.zhaobi.com/static/jquery-3.2.1.min.js"
></script>
</head>
<body>
<div
class=
"content"
>
<div
class=
"cookie_table"
>
<div
class=
"notice_box"
><span></span></div>
<table
class=
"dataintable"
>
<tr>
<th
width=
"50%"
>
COOKIE名
</th><th
width=
"50%"
>
COOKIE值(jira项目名-项目ID,如: TRADE-11)
</th>
</tr>
<tr>
<td>
<?php
echo
VERSION_KEY
;
?>
</td>
<td>
<input
type=
"text"
name=
"
<?php
echo
VERSION_KEY
;
?>
"
>
</td>
</tr>
<tr>
<td
colspan=
2
>
<div
class=
"btn_list"
>
<span
class=
"submit_cookie"
>
保存
</span>
<span
class=
"return_page"
>
关闭
</span>
</div>
</td>
</tr>
</table>
</div>
<div
class=
"service_header"
>
</div>
<div
class=
"app_print"
>
<h3>
原始APP输出内容
</h3>
<span>
<?php
echo
$ob_content
;
?>
</span>
</div>
</div>
<script>
$
(
".submit_cookie"
).
on
(
"click"
,
function
(){
$
(
".notice_box"
).
show
().
find
(
"span"
).
html
(
"查询处理结果中。。。"
);
var
cookie_val
=
$
(
"input[name='
<?php
echo
VERSION_KEY
;
?>
']"
).
val
();
var
script
=
document
.
createElement
(
'script'
);
script
.
type
=
'text/javascript'
;
script
.
src
=
location
.
href
+
"&set_cookie_val="
+
cookie_val
;
$
(
'body'
).
append
(
script
);
$
.
ajax
({
type
:
'HEAD'
,
// 获取头信息,type=HEAD即可
url
:
window
.
location
.
href
,
complete
:
function
(
xhr
,
data
){
// 获取相关Http Response header
var
wpoInfo
=
{
"fpf-version"
:
xhr
.
getResponseHeader
(
'fpf-version'
),
};
// 在这里,做想做的事。。。
if
(
wpoInfo
[
'fpf-version'
]){
var
str
=
wpoInfo
[
'fpf-version'
];
var
patt
=
/
(
file|cookie
)
-
([
a-zA-Z0-9
]
+
)
/
;
var
result
;
if
((
result
=
patt
.
exec
(
str
))
!=
null
)
{
var
type
=
result
[
1
];
var
version
=
result
[
2
];
var
type_desc
=
''
;
if
(
'file'
==
type
){
type_desc
=
'文件定义的版本号'
;
}
else
if
(
'cookie'
==
type
){
type_desc
=
'cookie版本'
;
}
$
(
".notice_box span"
).
html
(
"当前访问的是"
+
type_desc
+
", 版本号为"
+
version
);
}
else
{
$
(
".notice_box span"
).
html
(
"未知的版本类型:"
+
str
);
}
}
else
{
$
(
".notice_box span"
).
html
(
"您当前处于本地开发环境,无版本目录"
);
}
}
});
});
$
(
".return_page"
).
on
(
"click"
,
function
(){
var
link
=
location
.
href
;
link
=
link
.
replace
(
/cookie_edit=
(
1|true
)
/i
,
""
);
location
.
href
=
link
;
});
</script>
</body>
</html>
\ No newline at end of file
config/ip.php
0 → 100644
View file @
e3eefdf3
<?php
$config
[
'company_ip_list'
]
=
[
'122.224.77.186'
,
];
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment