mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
add get ip&schema function
This commit is contained in:
@@ -21,7 +21,7 @@ Complete PT website building solution. Based on NexusPHP + Laravel Framework + E
|
||||
- ....
|
||||
|
||||
## System Requirements
|
||||
- PHP: 8.0, must have extensions: bcmath, ctype, fileinfo, json, mbstring, openssl, pdo_mysql, tokenizer, xml, mysqli, gd, redis
|
||||
- PHP: 8.0, must have extensions: bcmath, ctype, fileinfo, json, mbstring, openssl, pdo_mysql, tokenizer, xml, mysqli, gd, redis, pcntl, sockets
|
||||
- Mysql: 5.7 latest version or above
|
||||
- Redis:1.0.0 or above
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
- ....
|
||||
|
||||
## 系统要求
|
||||
- PHP: 8.0,必须扩展:bcmath, ctype, fileinfo, json, mbstring, openssl, pdo_mysql, tokenizer, xml, mysqli, gd, redis
|
||||
- PHP: 8.0,必须扩展:bcmath, ctype, fileinfo, json, mbstring, openssl, pdo_mysql, tokenizer, xml, mysqli, gd, redis, pcntl, sockets
|
||||
- Mysql: 5.7最新版或以上版本
|
||||
- Redis:1.0.0或以上版本
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ class TrackerRepository extends BaseRepository
|
||||
}
|
||||
|
||||
// Part.4 Get User Ip Address
|
||||
$queries['ip'] = $request->getClientIp();
|
||||
$queries['ip'] = nexus()->getRequestIp();
|
||||
|
||||
// Part.5 Get Users Agent
|
||||
$queries['user_agent'] = $request->headers->get('user-agent');
|
||||
|
||||
@@ -443,15 +443,10 @@ function arr_set(&$array, $key, $value)
|
||||
return $array;
|
||||
}
|
||||
|
||||
function isHttps()
|
||||
function isHttps(): bool
|
||||
{
|
||||
if (RUNNING_IN_OCTANE) {
|
||||
$https = request()->server('HTTPS');
|
||||
$result = !empty($https) && (strtolower($https) !== 'off');
|
||||
} else {
|
||||
$result = !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) !== 'off');
|
||||
}
|
||||
return $result;
|
||||
$schema = nexus()->getRequestSchema();
|
||||
return $schema == 'https';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ $lang_functions = array
|
||||
'text_required' => '不能为空',
|
||||
'text_invalid' => '非法',
|
||||
'text_technical_info' => 'MediaInfo',
|
||||
'text_technical_info_help_text' => '文件 MediaInfo 来自软件 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用该软件打开文件,点击菜单视图(View)->文件(Text),在框中右键->全选,再右键->复制,粘贴到这里来。',
|
||||
'text_technical_info_help_text' => 'MediaInfo 来自软件 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用该软件打开文件,点击菜单视图(View)->文件(Text),在框中右键->全选,再右键->复制,粘贴到这里来。',
|
||||
'text_management_system' => '管理系统',
|
||||
'text_seed_points' => '做种积分',
|
||||
);
|
||||
|
||||
@@ -318,7 +318,7 @@ $lang_functions = array
|
||||
'text_required' => '不能為空',
|
||||
'text_invalid' => '非法',
|
||||
'text_technical_info' => 'MediaInfo',
|
||||
'text_technical_info_help_text' => '文件 MediaInfo 來自軟件 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用該軟件打開文件,點擊菜單視圖(View)->文件(Text),在框中右鍵->全選,再右鍵->復制,粘貼到這裏來。',
|
||||
'text_technical_info_help_text' => 'MediaInfo 來自軟件 <b><a href="https://mediaarea.net/en/MediaInfo" target=\'_blank\'>MediaInfo</a></b>,用該軟件打開文件,點擊菜單視圖(View)->文件(Text),在框中右鍵->全選,再右鍵->復制,粘貼到這裏來。',
|
||||
'text_management_system' => '管理系統',
|
||||
'text_seed_points' => '做種積分',
|
||||
);
|
||||
|
||||
@@ -128,7 +128,7 @@ class Install
|
||||
public function listRequirementTableRows()
|
||||
{
|
||||
$gdInfo = function_exists('gd_info') ? gd_info() : [];
|
||||
$extensions = ['ctype', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml', 'mysqli', 'bcmath', 'redis', 'gd', 'pcntl'];
|
||||
$extensions = ['ctype', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml', 'mysqli', 'bcmath', 'redis', 'gd', 'pcntl', 'sockets'];
|
||||
$tableRows = [];
|
||||
$tableRows[] = [
|
||||
'label' => 'PHP version',
|
||||
|
||||
@@ -92,6 +92,42 @@ final class Nexus
|
||||
$this->logSequence++;
|
||||
}
|
||||
|
||||
public function getRequestSchema()
|
||||
{
|
||||
$schema = $this->retrieveFromServer(['HTTP_X_FORWARDED_PROTO', 'REQUEST_SCHEME', 'HTTP_SCHEME']);
|
||||
if (empty($schema)) {
|
||||
$tmp = $this->retrieveFromServer(['HTTPS']);
|
||||
if ($tmp == 'on') {
|
||||
$schema = 'https';
|
||||
}
|
||||
}
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public function getRequestIp()
|
||||
{
|
||||
$ip = $this->retrieveFromServer(['HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_REMOTE_ADDR']);
|
||||
if (empty($ip)) {
|
||||
$ip = request()->getClientIp();
|
||||
}
|
||||
return $ip;
|
||||
}
|
||||
|
||||
private function retrieveFromServer(array $fields)
|
||||
{
|
||||
if ($this->runningInOctane()) {
|
||||
$servers = request()->server();
|
||||
} else {
|
||||
$servers = $_SERVER;
|
||||
}
|
||||
foreach ($fields as $field) {
|
||||
if (!empty($servers[$field])) {
|
||||
do_log("got from $field");
|
||||
return $servers[$field];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function runningInOctane(): bool
|
||||
{
|
||||
if (defined('RUNNING_IN_OCTANE') && RUNNING_IN_OCTANE) {
|
||||
|
||||
Reference in New Issue
Block a user