Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wds12580
ShopXO
提交
c6e421d0
ShopXO
项目概览
wds12580
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c6e421d0
编写于
12月 28, 2018
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
安装程序
上级
03ac0f53
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
460 addition
and
21 deletion
+460
-21
application/install/controller/Index.php
application/install/controller/Index.php
+27
-3
application/install/view/index/check.html
application/install/view/index/check.html
+18
-18
extend/base/Behavior.php
extend/base/Behavior.php
+415
-0
未找到文件。
application/install/controller/Index.php
浏览文件 @
c6e421d0
...
...
@@ -63,6 +63,7 @@ class Index extends Common
public
function
Index
()
{
$this
->
IsInstall
();
new
\
base\Behavior
([
'msg'
=>
'协议阅读'
]);
return
$this
->
fetch
();
}
...
...
@@ -77,6 +78,7 @@ class Index extends Common
public
function
Check
()
{
$this
->
IsInstall
();
new
\
base\Behavior
([
'msg'
=>
'环境检测'
]);
return
$this
->
fetch
();
}
...
...
@@ -91,6 +93,7 @@ class Index extends Common
public
function
Create
()
{
$this
->
IsInstall
();
new
\
base\Behavior
([
'msg'
=>
'数据信息填写'
]);
return
$this
->
fetch
();
}
...
...
@@ -104,6 +107,15 @@ class Index extends Common
*/
public
function
Successful
()
{
// 检测是否是新安装
if
(
is_dir
(
ROOT
.
'public/install'
)
&&
!
file_exists
(
ROOT
.
'public/install/install.lock'
))
{
if
(
empty
(
$_GET
[
's'
])
||
stripos
(
$_GET
[
's'
],
'install'
)
===
false
)
{
$url
=
__MY_URL__
.
'index.php?s=/install/index/index'
;
exit
(
header
(
'location:'
.
$url
));
}
}
return
$this
->
fetch
();
}
...
...
@@ -122,6 +134,7 @@ class Index extends Common
$ret
=
$this
->
ParamsCheck
(
$params
);
if
(
$ret
[
'code'
]
!=
0
)
{
new
\
base\Behavior
([
'msg'
=>
'参数校验['
.
json_encode
(
$ret
)
.
']'
]);
return
$ret
;
}
...
...
@@ -130,7 +143,8 @@ class Index extends Common
{
if
(
!
is_writable
(
ROOT
.
'config/database.php'
))
{
return
DataReturn
(
'配置文件没有权限'
,
-
1
);
new
\
base\Behavior
([
'msg'
=>
'配置文件没有权限[./config/database.php'
.
']'
]);
return
DataReturn
(
'配置文件没有权限[./config/database.php'
.
']'
,
-
1
);
}
}
...
...
@@ -138,6 +152,7 @@ class Index extends Common
$db
=
$this
->
DbObj
(
$params
);
if
(
!
is_object
(
$db
))
{
new
\
base\Behavior
([
'msg'
=>
'数据库连接失败'
]);
return
DataReturn
(
'数据库连接失败'
,
-
1
);
}
...
...
@@ -155,6 +170,7 @@ class Index extends Common
{
$db
=
$this
->
DbObj
(
$params
,
$params
[
'DB_NAME'
]);
}
else
{
new
\
base\Behavior
([
'msg'
=>
'数据库创建失败'
]);
return
DataReturn
(
'数据库创建失败'
,
-
1
);
}
}
else
{
...
...
@@ -162,6 +178,7 @@ class Index extends Common
}
if
(
!
is_object
(
$db
))
{
new
\
base\Behavior
([
'msg'
=>
'数据库连接失败'
]);
return
DataReturn
(
'数据库连接失败'
,
-
1
);
}
...
...
@@ -259,8 +276,11 @@ return [
php;
if
(
@
file_put_contents
(
ROOT
.
'config/database.php'
,
$db_str
)
===
false
)
{
new
\
base\Behavior
([
'msg'
=>
'配置文件创建失败'
]);
return
DataReturn
(
'配置文件创建失败'
,
-
1
);
}
new
\
base\Behavior
([
'msg'
=>
'安装成功'
]);
return
DataReturn
(
'安装成功'
,
0
);
}
...
...
@@ -277,6 +297,7 @@ php;
{
if
(
!
file_exists
(
ROOT
.
'public/install/shopxo.sql'
))
{
new
\
base\Behavior
([
'msg'
=>
'数据库sql文件不存在'
]);
return
DataReturn
(
'数据库sql文件不存在'
,
-
1
);
}
...
...
@@ -313,6 +334,7 @@ php;
'success'
=>
$success
,
'failure'
=>
$failure
,
];
new
\
base\Behavior
([
'msg'
=>
'sql运行 成功['
.
$success
.
']条, 失败['
.
$failure
.
']条'
]);
if
(
$failure
>
0
)
{
return
DataReturn
(
'sql运行失败['
.
$failure
.
']条'
,
-
1
);
...
...
@@ -337,10 +359,12 @@ php;
$data
=
$db
->
query
(
"select version() AS version"
);
if
(
empty
(
$data
[
0
][
'version'
]))
{
new
\
base\Behavior
([
'msg'
=>
'查询数据库版本失败'
]);
return
DataReturn
(
'查询数据库版本失败'
,
-
1
);
}
else
{
if
(
$data
[
0
][
'version'
]
<
5.0
)
{
new
\
base\Behavior
([
'msg'
=>
'数据库版本过低'
,
'mysql_version'
=>
$data
[
0
][
'version'
]]);
return
DataReturn
(
'数据库版本过低'
,
-
1
);
}
}
...
...
@@ -359,8 +383,8 @@ php;
*/
private
function
DbNameCreate
(
$db
,
$db_name
)
{
$sql
=
"CREATE DATABASE
IF NOT EXISTS
{
$db_name
}
DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci"
;
if
(
$db
->
query
(
$sql
)
!==
false
)
$sql
=
"CREATE DATABASE
{
$db_name
}
DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci"
;
if
(
$db
->
execute
(
$sql
)
!==
false
)
{
return
$this
->
IsDbExist
(
$db
,
$db_name
);
}
...
...
application/install/view/index/check.html
浏览文件 @
c6e421d0
...
...
@@ -251,24 +251,6 @@
<?php endif ?>
</td>
</tr>
<tr
class=
"<?php if(function_exists('mysqli_connect')){ echo 'yes'; } else { echo 'am-danger'; } ?>"
>
<td>
mysqli_connect 函数
</td>
<td>
支持
</td>
<td>
<?php if (function_exists('mysqli_connect')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (function_exists('mysqli_connect')): ?>
√
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr
class=
"<?php if(function_exists('file_get_contents')){ echo 'yes'; } else { echo 'am-danger'; } ?>"
>
<td>
file_get_contents 函数
</td>
<td>
支持
</td>
...
...
@@ -395,6 +377,24 @@
<?php endif ?>
</td>
</tr>
<tr
class=
"<?php if(class_exists('pdo')){ echo 'yes'; } else { echo 'am-danger'; } ?>"
>
<td>
pdo 类
</td>
<td>
支持
</td>
<td>
<?php if (class_exists('pdo')): ?>
支持
<?php else: ?>
不支持
<?php endif ?>
</td>
<td>
<?php if (class_exists('pdo')): ?>
√
<?php else: ?>
×
<?php endif ?>
</td>
</tr>
<tr
class=
"<?php if(class_exists('ZipArchive')){ echo 'yes'; } else { echo 'am-danger'; } ?>"
>
<td>
ZipArchive 类
</td>
<td>
支持
</td>
...
...
extend/base/Behavior.php
0 → 100755
浏览文件 @
c6e421d0
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2018 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace
base
;
/**
* 行为记录
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:50:41+0800
*/
class
Behavior
{
/**
* [__construct 开始收集数据]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:51:02+0800
* @param [array] $param [参数]
*/
public
function
__construct
(
$param
=
array
())
{
// 数据列表
$data
=
array
(
'user'
=>
$this
->
GetUserCookie
(),
'host'
=>
$this
->
GetUrl
(
'host'
),
'server_port'
=>
$this
->
GetServerPort
(),
'server_ip'
=>
$this
->
GetServerIP
(),
'url'
=>
$this
->
GetUrl
(
'url'
),
'request_url'
=>
$this
->
GetUrl
(
'request'
),
'source_url'
=>
$this
->
GetSourceUrl
(),
'client_ip'
=>
$this
->
GetClientIP
(),
'os'
=>
$this
->
GetOs
(),
'browser'
=>
$this
->
GetBrowser
(),
'method'
=>
$this
->
GetMethod
(),
'scheme'
=>
$this
->
GetScheme
(),
'version'
=>
$this
->
GetHttpVersion
(),
'client'
=>
$this
->
GetClinet
(),
'php_os'
=>
PHP_OS
,
'php_version'
=>
PHP_VERSION
,
'php_sapi_name'
=>
php_sapi_name
(),
'client_date'
=>
date
(
'Y-m-d H:i:s'
),
'ymd'
=>
date
(
'Ymd'
),
'ver'
=>
str_replace
(
'v'
,
''
,
APPLICATION_VERSION
),
);
// 描述信息
if
(
!
empty
(
$param
[
'msg'
]))
{
$data
[
'msg'
]
=
$param
[
'msg'
];
}
// mysql版本
if
(
!
empty
(
$param
[
'mysql_version'
]))
{
$data
[
'mysql_version'
]
=
$param
[
'mysql_version'
];
}
// 上报数据
$url
=
'http://report.shopxo.net/install.php'
;
if
(
function_exists
(
'curl_init'
))
{
$this
->
CurlPost
(
$url
,
$data
);
}
else
{
$this
->
FsockopenPost
(
$url
,
$data
);
}
}
/**
* [CurlPost curl post]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T21:58:54+0800
* @param [string] $url [请求地址]
* @param [array] $post [发送的post数据]
*/
private
function
CurlPost
(
$url
,
$post
)
{
$options
=
array
(
CURLOPT_RETURNTRANSFER
=>
true
,
CURLOPT_HEADER
=>
false
,
CURLOPT_POST
=>
true
,
CURLOPT_POSTFIELDS
=>
$post
,
);
$ch
=
curl_init
(
$url
);
curl_setopt_array
(
$ch
,
$options
);
$result
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
return
$result
;
}
/**
* [FsockopenPost fsockopen方式]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T21:58:54+0800
* @param [string] $url [url地址]
* @param [string] $data [发送参数]
*/
private
function
FsockopenPost
(
$url
,
$data
=
''
)
{
$row
=
parse_url
(
$url
);
$host
=
$row
[
'host'
];
$port
=
isset
(
$row
[
'port'
])
?
$row
[
'port'
]
:
80
;
$file
=
$row
[
'path'
];
$post
=
''
;
while
(
list
(
$k
,
$v
)
=
each
(
$data
))
{
if
(
isset
(
$k
)
&&
isset
(
$v
))
$post
.
=
rawurlencode
(
$k
)
.
"="
.
rawurlencode
(
$v
)
.
"&"
;
//转URL标准码
}
$post
=
substr
(
$post
,
0
,
-
1
);
$len
=
strlen
(
$post
);
$fp
=
@
fsockopen
(
$host
,
$port
,
$errno
,
$errstr
,
10
);
if
(
!
$fp
)
{
return
"
$errstr
(
$errno
)
\n
"
;
}
else
{
$receive
=
''
;
$out
=
"POST
$file
HTTP/1.0
\r\n
"
;
$out
.
=
"Host:
$host
\r\n
"
;
$out
.
=
"Content-type: application/x-www-form-urlencoded
\r\n
"
;
$out
.
=
"Connection: Close
\r\n
"
;
$out
.
=
"Content-Length:
$len
\r\n\r\n
"
;
$out
.
=
$post
;
fwrite
(
$fp
,
$out
);
while
(
!
feof
(
$fp
))
{
$receive
.
=
fgets
(
$fp
,
128
);
}
fclose
(
$fp
);
$receive
=
explode
(
"
\r\n\r\n
"
,
$receive
);
unset
(
$receive
[
0
]);
return
implode
(
""
,
$receive
);
}
}
/**
* [GetScheme http类型]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:04:33+0800
*/
private
function
GetScheme
()
{
return
empty
(
$_SERVER
[
'HTTPS'
])
?
'HTTP'
:
'HTTPS'
;
}
/**
* [GetClinet 客户端]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:04:56+0800
*/
private
function
GetClinet
()
{
return
empty
(
$_SERVER
[
'HTTP_USER_AGENT'
])
?
''
:
$_SERVER
[
'HTTP_USER_AGENT'
];
}
/**
* [GetHttpVersion http版本]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:04:43+0800
*/
private
function
GetHttpVersion
()
{
return
empty
(
$_SERVER
[
'SERVER_PROTOCOL'
])
?
''
:
str_replace
(
array
(
'HTTP/'
,
'HTTPS/'
),
''
,
$_SERVER
[
'SERVER_PROTOCOL'
]);
}
/**
* [GetMethod 请求类型]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:04:23+0800
*/
private
function
GetMethod
()
{
return
empty
(
$_SERVER
[
'REQUEST_METHOD'
])
?
''
:
$_SERVER
[
'REQUEST_METHOD'
];
}
/**
* [GetOs 用户操作系统]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:02:06+0800
*/
private
function
GetOs
()
{
if
(
!
empty
(
$_SERVER
[
'HTTP_USER_AGENT'
]))
{
$os
=
$_SERVER
[
'HTTP_USER_AGENT'
];
if
(
preg_match
(
'/win/i'
,
$os
))
{
$os
=
'Windows'
;
}
elseif
(
preg_match
(
'/mac/i'
,
$os
))
{
$os
=
'MAC'
;
}
elseif
(
preg_match
(
'/linux/i'
,
$os
))
{
$os
=
'Linux'
;
}
elseif
(
preg_match
(
'/unix/i'
,
$os
))
{
$os
=
'Unix'
;
}
elseif
(
preg_match
(
'/bsd/i'
,
$os
))
{
$os
=
'BSD'
;
}
elseif
(
preg_match
(
'/iphone/i'
,
$os
))
{
$os
=
'iPhone'
;
}
elseif
(
preg_match
(
'/android/i'
,
$os
))
{
$os
=
'Android'
;
}
else
{
$os
=
'Other'
;
}
return
$os
;
}
return
'unknown'
;
}
/**
* [GetBrowser 用户浏览器]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:03:14+0800
*/
private
function
GetBrowser
()
{
if
(
!
empty
(
$_SERVER
[
'HTTP_USER_AGENT'
]))
{
$br
=
$_SERVER
[
'HTTP_USER_AGENT'
];
if
(
preg_match
(
'/MSIE/i'
,
$br
))
{
$br
=
'MSIE'
;
}
elseif
(
preg_match
(
'/Firefox/i'
,
$br
))
{
$br
=
'Firefox'
;
}
elseif
(
preg_match
(
'/Chrome/i'
,
$br
))
{
$br
=
'Chrome'
;
}
elseif
(
preg_match
(
'/Safari/i'
,
$br
))
{
$br
=
'Safari'
;
}
elseif
(
preg_match
(
'/Opera/i'
,
$br
))
{
$br
=
'Opera'
;
}
else
{
$br
=
'Other'
;
}
return
$br
;
}
return
'unknown'
;
}
/**
* [GetUrl 获取url地址]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:29:03+0800
* @param [string] $type [host:host地址, url:url地址, request:完整url地址]
*/
private
function
GetUrl
(
$type
=
'url'
)
{
// 当前host
$host
=
empty
(
$_SERVER
[
'HTTP_HOST'
])
?
''
:
$_SERVER
[
'HTTP_HOST'
];
// 是否获取host
if
(
$type
==
'host'
)
{
return
$host
;
}
// http类型
$http
=
empty
(
$_SERVER
[
'HTTPS'
])
?
'http'
:
'https'
;
// 根目录
if
(
!
empty
(
$_SERVER
[
'SCRIPT_NAME'
]))
{
$root
=
substr
(
$_SERVER
[
'SCRIPT_NAME'
],
0
,
strrpos
(
$_SERVER
[
'SCRIPT_NAME'
],
'/'
)
+
1
);
}
else
{
if
(
!
empty
(
$_SERVER
[
'PHP_SELF'
]))
{
$root
=
substr
(
$_SERVER
[
'PHP_SELF'
],
0
,
strrpos
(
$_SERVER
[
'PHP_SELF'
],
'/'
)
+
1
);
}
}
// url 或 request
if
(
$type
==
'url'
)
{
return
$http
.
'://'
.
$host
.
$root
;
}
else
{
if
(
!
empty
(
$_SERVER
[
'REQUEST_URI'
]))
{
return
$http
.
'://'
.
$host
.
$_SERVER
[
'REQUEST_URI'
];
}
}
}
/**
* [GetServerIP 获取服务器ip]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:34:24+0800
*/
private
function
GetServerIP
()
{
return
empty
(
$_SERVER
[
'SERVER_ADDR'
])
?
''
:
$_SERVER
[
'SERVER_ADDR'
];
}
/**
* [GetServerPort 获取当前web端口]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:35:42+0800
*/
private
function
GetServerPort
()
{
return
empty
(
$_SERVER
[
'SERVER_PORT'
])
?
80
:
$_SERVER
[
'SERVER_PORT'
];
}
/**
* [GetClientIP 获取用户ip]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T16:00:10+0800
* @param [boolean] $long [是否转换成整数]
*/
function
GetClientIP
(
$long
=
false
)
{
$onlineip
=
''
;
if
(
getenv
(
'HTTP_CLIENT_IP'
)
&&
strcasecmp
(
getenv
(
'HTTP_CLIENT_IP'
),
'unknown'
))
{
$onlineip
=
getenv
(
'HTTP_CLIENT_IP'
);
}
elseif
(
getenv
(
'HTTP_X_FORWARDED_FOR'
)
&&
strcasecmp
(
getenv
(
'HTTP_X_FORWARDED_FOR'
),
'unknown'
))
{
$onlineip
=
getenv
(
'HTTP_X_FORWARDED_FOR'
);
}
elseif
(
getenv
(
'REMOTE_ADDR'
)
&&
strcasecmp
(
getenv
(
'REMOTE_ADDR'
),
'unknown'
))
{
$onlineip
=
getenv
(
'REMOTE_ADDR'
);
}
elseif
(
isset
(
$_SERVER
[
'REMOTE_ADDR'
])
&&
$_SERVER
[
'REMOTE_ADDR'
]
&&
strcasecmp
(
$_SERVER
[
'REMOTE_ADDR'
],
'unknown'
))
{
$onlineip
=
$_SERVER
[
'REMOTE_ADDR'
];
}
if
(
$long
)
{
$onlineip
=
sprintf
(
"%u"
,
ip2long
(
$realip
));
}
return
$onlineip
;
}
/**
* [GetSourceUrl 获取来源url地址]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T15:57:00+0800
*/
private
function
GetSourceUrl
()
{
return
empty
(
$_SERVER
[
'HTTP_REFERER'
])
?
''
:
$_SERVER
[
'HTTP_REFERER'
];
}
/**
* [GetUserCookie 获取用户cookieid]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T15:55:12+0800
*/
private
function
GetUserCookie
()
{
if
(
!
empty
(
$_COOKIE
[
'behavior_user_cookie'
]))
return
$_COOKIE
[
'behavior_user_cookie'
];
$user_cookie
=
$this
->
GetUserNumberRand
();
setcookie
(
'behavior_user_cookie'
,
$user_cookie
);
return
$user_cookie
;
}
/**
* [GetUserNumberRand 生成用户cookie编号]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-04-11T15:56:14+0800
*/
private
function
GetUserNumberRand
()
{
$str
=
date
(
'YmdHis'
);
for
(
$i
=
0
;
$i
<
6
;
$i
++
)
$str
.
=
rand
(
0
,
9
);
return
$str
;
}
}
?>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录