Add support for REQUEST_TIME_FLOAT which returns secs.usec since epoch
Zend compat http://php.net/manual/en/reserved.variables.server.php closes 778
Esse commit está contido em:
@@ -445,6 +445,7 @@ static const StaticString
|
||||
s_HHVM_JIT("HHVM_JIT"),
|
||||
s_REQUEST_START_TIME("REQUEST_START_TIME"),
|
||||
s_REQUEST_TIME("REQUEST_TIME"),
|
||||
s_REQUEST_TIME_FLOAT("REQUEST_TIME_FLOAT"),
|
||||
s_DOCUMENT_ROOT("DOCUMENT_ROOT"),
|
||||
s_SCRIPT_FILENAME("SCRIPT_FILENAME"),
|
||||
s_SCRIPT_NAME("SCRIPT_NAME"),
|
||||
@@ -480,9 +481,19 @@ void execute_command_line_begin(int argc, char **argv, int xhprof) {
|
||||
|
||||
Variant &server = g->GV(_SERVER);
|
||||
process_env_variables(server);
|
||||
time_t now = time(nullptr);
|
||||
time_t now;
|
||||
struct timeval tp = {0};
|
||||
double now_double;
|
||||
if (!gettimeofday(&tp, nullptr)) {
|
||||
now_double = (double)(tp.tv_sec + tp.tv_usec / 1000000.00);
|
||||
now = tp.tv_sec;
|
||||
} else {
|
||||
now = time(nullptr);
|
||||
now_double = (double)now;
|
||||
}
|
||||
server.set(s_REQUEST_START_TIME, now);
|
||||
server.set(s_REQUEST_TIME, now);
|
||||
server.set(s_REQUEST_TIME_FLOAT, now_double);
|
||||
server.set(s_DOCUMENT_ROOT, empty_string);
|
||||
server.set(s_SCRIPT_FILENAME, argv[0]);
|
||||
server.set(s_SCRIPT_NAME, argv[0]);
|
||||
|
||||
@@ -14,9 +14,8 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include "hphp/runtime/base/hphp_system.h"
|
||||
#include "hphp/runtime/base/server/http_protocol.h"
|
||||
#include "hphp/runtime/base/hphp_system.h"
|
||||
#include "hphp/runtime/base/zend/zend_url.h"
|
||||
#include "hphp/runtime/base/zend/zend_string.h"
|
||||
#include "hphp/runtime/base/program_functions.h"
|
||||
@@ -111,6 +110,7 @@ static const StaticString
|
||||
s_HTTPS("HTTPS"),
|
||||
s_1("1"),
|
||||
s_REQUEST_TIME("REQUEST_TIME"),
|
||||
s_REQUEST_TIME_FLOAT("REQUEST_TIME_FLOAT"),
|
||||
s_QUERY_STRING("QUERY_STRING"),
|
||||
s_REMOTE_ADDR("REMOTE_ADDR"),
|
||||
s_REMOTE_HOST("REMOTE_HOST"),
|
||||
@@ -388,8 +388,19 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport,
|
||||
break;
|
||||
default: server.set(s_REQUEST_METHOD, empty_string); break;
|
||||
}
|
||||
time_t now;
|
||||
struct timeval tp = {0};
|
||||
double now_double;
|
||||
if (!gettimeofday(&tp, nullptr)) {
|
||||
now_double = (double)(tp.tv_sec + tp.tv_usec / 1000000.00);
|
||||
now = tp.tv_sec;
|
||||
} else {
|
||||
now = time(nullptr);
|
||||
now_double = (double)now;
|
||||
}
|
||||
server.set(s_HTTPS, transport->isSSL() ? s_1 : empty_string);
|
||||
server.set(s_REQUEST_TIME, time(nullptr));
|
||||
server.set(s_REQUEST_TIME, now);
|
||||
server.set(s_REQUEST_TIME_FLOAT, now_double);
|
||||
server.set(s_QUERY_STRING, r.queryString());
|
||||
|
||||
server.set(s_REMOTE_ADDR, String(transport->getRemoteHost(), CopyString));
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário