本文整理汇总了C++中php_request_shutdown函数的典型用法代码示例。如果您正苦于以下问题:C++ php_request_shutdown函数的具体用法?C++ php_request_shutdown怎么用?C++ php_request_shutdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了php_request_shutdown函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mlfi_init
/* {{{ Init Milter
*/
static int mlfi_init()
{
int ret = 0;
zend_file_handle file_handle;
zval function_name, retval;
int status;
TSRMLS_FETCH();
/* request startup */
if (php_request_startup(TSRMLS_C)==FAILURE) {
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
php_request_shutdown((void *) 0);
return -1;
}
/* disable headers */
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
if (filename == NULL) {
php_printf("No input file specified");
return SMFIS_TEMPFAIL;
}
if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) {
php_printf("Could not open input file: %s\n", filename);
return SMFIS_TEMPFAIL;
}
file_handle.type = ZEND_HANDLE_FP;
file_handle.filename = filename;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_execute_script(&file_handle TSRMLS_CC);
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_init", 0);
/* set the milter context for possible use in API functions */
MG(state) = MLFI_INIT;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL TSRMLS_CC);
MG(state) = MLFI_NONE;
MG(initialized) = 1;
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
ret = Z_LVAL(retval);
}
php_request_shutdown((void *) 0);
return ret;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:61,代码来源:php_milter.c
示例2: webjames_php_close
static void webjames_php_close(struct connection *conn, int force)
/*called by webjames if it wants to close the connection*/
{
php_request_shutdown(NULL);
WG(oldclose)(conn,force);
}
开发者ID:chosen1,项目名称:php-src,代码行数:7,代码来源:webjames.c
示例3: lsapi_module_main
static int lsapi_module_main(int show_source)
{
zend_file_handle file_handle = {0};
if (php_request_startup() == FAILURE ) {
return -1;
}
if (parse_user_ini && lsapi_activate_user_ini() == FAILURE) {
return -1;
}
if (show_source) {
zend_syntax_highlighter_ini syntax_highlighter_ini;
php_get_highlight_struct(&syntax_highlighter_ini);
highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini);
} else {
lsapi_execute_script( &file_handle);
}
zend_try {
php_request_shutdown(NULL);
memset( argv0, 0, 46 );
} zend_end_try();
return 0;
}
开发者ID:stamhe,项目名称:php-src,代码行数:26,代码来源:lsapi_main.c
示例4: mlfi_connect
/* {{{ mlfi_connect()
*/
static sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
{
zend_file_handle file_handle;
zval function_name, retval, *param[1];
int status;
TSRMLS_FETCH();
/* request startup */
if (php_request_startup(TSRMLS_C)==FAILURE) {
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
php_request_shutdown((void *) 0);
return SMFIS_TEMPFAIL;
}
/* disable headers */
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
if (filename == NULL) {
php_printf("No input file specified");
return SMFIS_TEMPFAIL;
}
if (!(file_handle.handle.fp = VCWD_FOPEN(filename, "rb"))) {
php_printf("Could not open input file: %s\n", filename);
return SMFIS_TEMPFAIL;
}
file_handle.type = ZEND_HANDLE_FP;
file_handle.filename = filename;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_execute_script(&file_handle TSRMLS_CC);
/* call userland */
INIT_ZVAL(function_name);
ALLOC_ZVAL(param[0]);
INIT_PZVAL(param[0]);
ZVAL_STRING(&function_name, "milter_connect", 0);
ZVAL_STRING(param[0], hostname, 1);
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_CONNECT;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 1, param TSRMLS_CC);
MG(state) = MLFI_NONE;
zval_ptr_dtor(param);
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
return Z_LVAL(retval);
}
return SMFIS_CONTINUE;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:62,代码来源:php_milter.c
示例5: mlfi_close
/* {{{ mlfi_close()
*/
static sfsistat mlfi_close(SMFICTX *ctx)
{
int ret = SMFIS_CONTINUE;
zval function_name, retval;
int status;
TSRMLS_FETCH();
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_close", 0);
/* set the milter context for possible use in API functions */
MG(ctx) = ctx;
MG(state) = MLFI_CLOSE;
status = call_user_function(CG(function_table), NULL, &function_name, &retval, 0, NULL TSRMLS_CC);
MG(state) = MLFI_NONE;
if (status == SUCCESS && Z_TYPE(retval) == IS_LONG) {
ret = Z_LVAL(retval);
}
php_request_shutdown((void *) 0);
return ret;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:29,代码来源:php_milter.c
示例6: exec_php
/**
* Gets the contents of the BLOB b and offers it to Zend for parsing/execution
*/
void exec_php(BLOBCALLBACK b, PARAMDSC *res, ISC_SHORT *init)
{
int result, remaining = b->blob_total_length, i = 0;
char *code = pemalloc(remaining+1, 1);
ISC_USHORT read;
for (code[remaining] = '\0'; remaining > 0; remaining -= read)
b->blob_get_segment(b->blob_handle, &code[i++<<16],min(0x10000,remaining), &read);
LOCK();
switch (init && *init) {
default:
#ifdef PHP_EMBED
php_request_shutdown(NULL);
if (FAILURE == (result = php_request_startup(TSRMLS_C))) {
break;
}
case 0:
#endif
/* feed it to the parser */
zend_first_try {
result = zend_eval_stringl(code, b->blob_total_length, NULL, "Firebird Embedded PHP engine" TSRMLS_CC);
} zend_end_try();
}
UNLOCK();
free(code);
res->dsc_dtype = dtype_long;
*(ISC_LONG*)res->dsc_address = (result == SUCCESS);
}
开发者ID:1HLtd,项目名称:php-src,代码行数:37,代码来源:php_ibase_udf.c
示例7: webjames_module_main
static void webjames_module_main(void)
{
zend_file_handle file_handle;
FILE *fp=NULL;
char *path;
/* Convert filename to Unix format*/
__riscosify_control|=__RISCOSIFY_STRICT_UNIX_SPECS;
path = __unixify(WG(conn)->filename,0,NULL,1024,0);
if (path) SG(request_info).path_translated = estrdup(path);
SG(request_info).query_string = WG(conn)->args;
SG(request_info).request_uri = WG(conn)->requesturi;
SG(request_info).request_method = WG(conn)->methodstr;
if (WG(conn)->method==METHOD_HEAD) {
SG(request_info).headers_only = 1;
} else {
SG(request_info).headers_only = 0;
}
SG(sapi_headers).http_response_code = 200;
SG(request_info).content_type = WG(conn)->type;
SG(request_info).content_length = WG(conn)->bodysize;
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
if (WG(conn)->authorization) {
char *colon=strchr(WG(conn)->authorization,':');
if (colon) {
SG(request_info).auth_user = emalloc(colon-WG(conn)->authorization+1);
if (SG(request_info).auth_user) {
memcpy(SG(request_info).auth_user,WG(conn)->authorization,colon-WG(conn)->authorization);
SG(request_info).auth_user[colon-WG(conn)->authorization]='\0';
SG(request_info).auth_password = estrdup(colon+1);
}
}
}
/*ensure that syslog calls get logged separately from WebJames' main log */
openlog("PHP",0,0);
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
if (php_request_startup() == FAILURE) {
return;
}
php_execute_script(&file_handle);
php_request_shutdown(NULL);
}
开发者ID:chosen1,项目名称:php-src,代码行数:52,代码来源:webjames.c
示例8: php_embed_shutdown
EMBED_SAPI_API void php_embed_shutdown(void)
{
php_request_shutdown((void *) 0);
php_module_shutdown();
sapi_shutdown();
#ifdef ZTS
tsrm_shutdown();
#endif
if (php_embed_module.ini_entries) {
free(php_embed_module.ini_entries);
php_embed_module.ini_entries = NULL;
}
}
开发者ID:CooCoooo,项目名称:php-src,代码行数:13,代码来源:php_embed.c
示例9: capi_module_main
int capi_module_main(NSLS_D)
{
zend_file_handle file_handle;
if (php_request_startup() == FAILURE) {
return FAILURE;
}
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_execute_script(&file_handle);
php_request_shutdown(NULL);
return SUCCESS;
}
开发者ID:slusarz,项目名称:php-src,代码行数:17,代码来源:capi.c
示例10: php_apache_request_dtor
static void php_apache_request_dtor(ap_filter_t *f)
{
php_apr_bucket_brigade *pbb = (php_apr_bucket_brigade *)f->ctx;
php_request_shutdown(NULL);
if (SG(request_info).query_string) {
free(SG(request_info).query_string);
}
if (SG(request_info).request_uri) {
free(SG(request_info).request_uri);
}
if (SG(request_info).path_translated) {
free(SG(request_info).path_translated);
}
apr_brigade_destroy(pbb->bb);
}
开发者ID:chosen1,项目名称:php-src,代码行数:18,代码来源:sapi_apache2.c
示例11: execPhpScript
int
execPhpScript( char *scrFile, int scrArgc, char **scrArgv ) {
zend_file_handle file_handle;
int status = 0;
int lineno = 0;
if ( ( status = php_seek_file_begin( &file_handle, scrFile, &lineno TSRMLS_CC ) )
< 0 ) {
rodsLog( LOG_ERROR,
"execPhpScript: php_seek_file_begin error for %s", scrFile );
return status;
}
file_handle.type = ZEND_HANDLE_FP;
file_handle.opened_path = NULL;
file_handle.free_filename = 0;
SG( request_info ).argc = scrArgc;
SG( request_info ).path_translated = file_handle.filename;
SG( request_info ).argv = scrArgv;
if ( php_request_startup( TSRMLS_C ) == FAILURE ) {
rodsLog( LOG_ERROR,
"execPhpScript: php_request_startup error for %s", scrFile );
fclose( file_handle.handle.fp );
return PHP_REQUEST_STARTUP_ERR;
}
CG( start_lineno ) = lineno;
zend_is_auto_global( "_SERVER", sizeof( "_SERVER" ) - 1 TSRMLS_CC );
PG( during_request_startup ) = 0;
php_execute_script( &file_handle TSRMLS_CC );
status = EG( exit_status );
if ( status != SUCCESS ) {
rodsLog( LOG_ERROR,
"execPhpScript: php_execute_script error for %s", scrFile );
status = PHP_EXEC_SCRIPT_ERR;
}
php_request_shutdown( ( void * ) 0 );
return status;
}
开发者ID:bpow,项目名称:irods,代码行数:43,代码来源:phptest.cpp
示例12: php_ns_module_main
static int
php_ns_module_main(void)
{
zend_file_handle file_handle;
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = SG(request_info).path_translated;
file_handle.free_filename = 0;
file_handle.opened_path = NULL;
php_ns_config(global_context, 0);
if (php_request_startup() == FAILURE) {
return NS_ERROR;
}
php_execute_script(&file_handle);
php_request_shutdown(NULL);
return NS_OK;
}
开发者ID:AmesianX,项目名称:php-src,代码行数:20,代码来源:aolserver.c
示例13: apache_php_module_main
/* {{{ apache_php_module_main
*/
int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
{
int retval = OK;
zend_file_handle file_handle;
if (php_request_startup(TSRMLS_C) == FAILURE) {
return FAILURE;
}
/* sending a file handle to another dll is not working
so let zend open it. */
if (display_source_mode) {
zend_syntax_highlighter_ini syntax_highlighter_ini;
php_get_highlight_struct(&syntax_highlighter_ini);
if (highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC) != SUCCESS) {
retval = NOT_FOUND;
}
} else {
file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.handle.fd = 0;
file_handle.filename = SG(request_info).path_translated;
file_handle.opened_path = NULL;
file_handle.free_filename = 0;
(void) php_execute_script(&file_handle TSRMLS_CC);
}
AP(in_request) = 0;
zend_try {
php_request_shutdown(NULL);
} zend_end_try();
return retval;
}
开发者ID:austintgriffith,项目名称:php7,代码行数:38,代码来源:sapi_apache.c
示例14: TSRMLS_FETCH
int MaPhp4Handler::run(MaRequest *rq)
{
MaDataStream *dynBuf;
MprHashTable *env;
MprStringHashEntry *vp;
int flags, contentLength;
hitCount++;
flags= rq->getFlags();
dynBuf = rq->getDynBuf();
rq->insertDataStream(dynBuf);
rq->setResponseCode(200);
rq->setHeaderFlags(MPR_HTTP_DONT_CACHE);
rq->setPullPost();
//
// Initialize PHP
//
TSRMLS_FETCH();
zend_first_try {
phpInitialized = 0;
func_data = rq;
var_array = 0;
SG(server_context) = rq;
SG(request_info).path_translated = rq->getFileName();
SG(request_info).request_method = rq->getMethod();
SG(request_info).request_uri = rq->getUri();
SG(request_info).query_string = rq->getQueryString();
SG(request_info).content_type = rq->getRequestContentMimeType();
SG(request_info).content_length = rq->getContentLength();
SG(sapi_headers).http_response_code = 200;
SG(request_info).auth_user = rq->getUser();
SG(request_info).auth_password = rq->getPassword();
php_request_startup(TSRMLS_C);
CG(zend_lineno) = 0;
} zend_catch {
mprLog(1, log, "PHP startup failed\n");
zend_try {
php_request_shutdown(0);
} zend_end_try();
rq->requestError(MPR_HTTP_INTERNAL_SERVER_ERROR,
"PHP initialization failed");
return MPR_HTTP_HANDLER_FINISHED_PROCESSING;
} zend_end_try();
phpInitialized = 1;
//
// Copy the environment variables to the PHP script engine
//
env = rq->getEnv();
vp = (MprStringHashEntry*) env->getFirst();
while (vp) {
php_register_variable(vp->getKey(), vp->getValue(),
var_array TSRMLS_CC);
vp = (MprStringHashEntry*) env->getNext(vp);
}
//
// Execute the PHP script
//
if (execScript(rq) < 0) {
zend_try {
php_request_shutdown(0);
} zend_end_try();
rq->requestError(MPR_HTTP_INTERNAL_SERVER_ERROR,
"PHP script execution failed");
return MPR_HTTP_HANDLER_FINISHED_PROCESSING;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:78,代码来源:php4Handler.cpp
示例15: ts_resource_ex
int32_t ScriptEngine::executeWebRequest(const std::string& path, BaseLib::HTTP& request, std::shared_ptr<BaseLib::Rpc::ServerInfo::Info>& serverInfo, std::shared_ptr<BaseLib::SocketOperations>& socket)
{
if(_disposing) return 1;
if(!GD::bl->io.fileExists(path))
{
GD::out.printError("Error: PHP script \"" + path + "\" does not exist.");
return -1;
}
ts_resource_ex(0, NULL); //Replaces TSRMLS_FETCH()
try
{
zend_file_handle script;
script.type = ZEND_HANDLE_FILENAME;
script.filename = path.c_str();
script.opened_path = NULL;
script.free_filename = 0;
zend_homegear_globals* globals = php_homegear_get_globals();
if(!globals)
{
ts_free_thread();
return -1;
}
globals->socket = socket.get();
globals->http = &request;
if(!tsrm_get_ls_cache())
{
GD::out.printCritical("Critical: Error in PHP: No thread safe resource exists (1).");
ts_free_thread();
return -1;
}
if(!((sapi_globals_struct *) (*((void ***) tsrm_get_ls_cache()))[((sapi_globals_id)-1)]))
{
GD::out.printCritical("Critical: Error in PHP: No thread safe resource exists (2).");
ts_free_thread();
return -1;
}
SG(server_context) = (void*)serverInfo.get(); //Must be defined! Otherwise POST data is not processed.
SG(sapi_headers).http_response_code = 200;
SG(default_mimetype) = nullptr;
SG(default_charset) = nullptr;
SG(request_info).content_length = request.getHeader()->contentLength;
if(!request.getHeader()->contentType.empty()) SG(request_info).content_type = request.getHeader()->contentType.c_str();
SG(request_info).request_method = request.getHeader()->method.c_str();
SG(request_info).proto_num = request.getHeader()->protocol == BaseLib::HTTP::Protocol::http10 ? 1000 : 1001;
std::string uri = request.getHeader()->path + request.getHeader()->pathInfo;
if(!request.getHeader()->args.empty()) uri.append('?' + request.getHeader()->args);
if(!request.getHeader()->args.empty()) SG(request_info).query_string = estrndup(&request.getHeader()->args.at(0), request.getHeader()->args.size());
if(!uri.empty()) SG(request_info).request_uri = estrndup(&uri.at(0), uri.size());
std::string pathTranslated = serverInfo->contentPath.substr(0, serverInfo->contentPath.size() - 1) + request.getHeader()->pathInfo;
SG(request_info).path_translated = estrndup(&pathTranslated.at(0), pathTranslated.size());
if (php_request_startup() == FAILURE) {
GD::bl->out.printError("Error calling php_request_startup...");
ts_free_thread();
return 1;
}
php_execute_script(&script);
int32_t exitCode = EG(exit_status);
if(SG(request_info).query_string)
{
efree(SG(request_info).query_string);
SG(request_info).query_string = nullptr;
}
if(SG(request_info).request_uri)
{
efree(SG(request_info).request_uri);
SG(request_info).request_uri = nullptr;
}
if(SG(request_info).path_translated)
{
efree(SG(request_info).path_translated);
SG(request_info).path_translated = nullptr;
}
php_request_shutdown(NULL);
ts_free_thread();
return exitCode;
}
catch(const std::exception& ex)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(BaseLib::Exception& ex)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(...)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
}
std::string error("Error executing script. Check Homegear log for more details.");
if(socket) php_homegear_write_socket(socket.get(), error.c_str(), error.length());
if(SG(request_info).query_string)
//.........这里部分代码省略.........
开发者ID:pauxus,项目名称:Homegear,代码行数:101,代码来源:ScriptEngine.cpp
示例16: setThreadNotRunning
//.........这里部分代码省略.........
return;
}
if(exitCode) *exitCode = -1;
if(!GD::bl->io.fileExists(path))
{
GD::out.printError("Error: PHP script \"" + path + "\" does not exist.");
setThreadNotRunning(threadId);
return;
}
ts_resource_ex(0, NULL); //Replaces TSRMLS_FETCH()
try
{
zend_file_handle script;
/* Set up a File Handle structure */
script.type = ZEND_HANDLE_FILENAME;
script.filename = path.c_str();
script.opened_path = NULL;
script.free_filename = 0;
zend_homegear_globals* globals = php_homegear_get_globals();
if(!globals)
{
ts_free_thread();
setThreadNotRunning(threadId);
return;
}
globals->output = output.get();
globals->commandLine = true;
globals->cookiesParsed = true;
if(!tsrm_get_ls_cache() || !((sapi_globals_struct *) (*((void ***) tsrm_get_ls_cache()))[((sapi_globals_id)-1)]) || !((php_core_globals *) (*((void ***) tsrm_get_ls_cache()))[((core_globals_id)-1)]))
{
GD::out.printCritical("Critical: Error in PHP: No thread safe resource exists.");
ts_free_thread();
setThreadNotRunning(threadId);
return;
}
PG(register_argc_argv) = 1;
SG(server_context) = (void*)output.get(); //Must be defined! Otherwise php_homegear_activate is not called.
SG(options) |= SAPI_OPTION_NO_CHDIR;
SG(headers_sent) = 1;
SG(request_info).no_headers = 1;
SG(default_mimetype) = nullptr;
SG(default_charset) = nullptr;
SG(request_info).path_translated = estrndup(path.c_str(), path.size());
if (php_request_startup(TSRMLS_C) == FAILURE) {
GD::bl->out.printError("Error calling php_request_startup...");
ts_free_thread();
setThreadNotRunning(threadId);
return;
}
std::vector<std::string> argv = getArgs(path, arguments);
php_homegear_build_argv(argv);
SG(request_info).argc = argv.size();
SG(request_info).argv = (char**)malloc((argv.size() + 1) * sizeof(char*));
for(uint32_t i = 0; i < argv.size(); ++i)
{
SG(request_info).argv[i] = (char*)argv[i].c_str(); //Value is not modified.
}
SG(request_info).argv[argv.size()] = nullptr;
php_execute_script(&script);
if(exitCode) *exitCode = EG(exit_status);
php_request_shutdown(NULL);
if(output->size() > 0)
{
std::string outputString(&output->at(0), output->size());
if(BaseLib::HelperFunctions::trim(outputString).size() > 0) GD::out.printMessage("Script output:\n" + outputString);
}
}
catch(const std::exception& ex)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(BaseLib::Exception& ex)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(...)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
}
if(SG(request_info).path_translated)
{
efree(SG(request_info).query_string);
SG(request_info).query_string = nullptr;
}
if(SG(request_info).argv)
{
free(SG(request_info).argv);
SG(request_info).argv = nullptr;
}
SG(request_info).argc = 0;
ts_free_thread();
setThreadNotRunning(threadId);
}
开发者ID:pauxus,项目名称:Homegear,代码行数:101,代码来源:ScriptEngine.cpp
示例17: do_cli
//.........这里部分代码省略.........
case PHP_MODE_REFLECTION_EXTENSION:
case PHP_MODE_REFLECTION_ZEND_EXTENSION:
{
zend_class_entry *pce = NULL;
zval arg, ref;
zend_execute_data execute_data;
switch (behavior) {
default:
break;
case PHP_MODE_REFLECTION_FUNCTION:
if (strstr(reflection_what, "::")) {
pce = reflection_method_ptr;
} else {
pce = reflection_function_ptr;
}
break;
case PHP_MODE_REFLECTION_CLASS:
pce = reflection_class_ptr;
break;
case PHP_MODE_REFLECTION_EXTENSION:
pce = reflection_extension_ptr;
break;
case PHP_MODE_REFLECTION_ZEND_EXTENSION:
pce = reflection_zend_extension_ptr;
break;
}
ZVAL_STRING(&arg, reflection_what);
object_init_ex(&ref, pce);
memset(&execute_data, 0, sizeof(zend_execute_data));
EG(current_execute_data) = &execute_data;
zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, &arg);
if (EG(exception)) {
zval tmp, *msg, rv;
ZVAL_OBJ(&tmp, EG(exception));
msg = zend_read_property(zend_ce_exception, &tmp, "message", sizeof("message")-1, 0, &rv);
zend_printf("Exception: %s\n", Z_STRVAL_P(msg));
zval_ptr_dtor(&tmp);
EG(exception) = NULL;
} else {
zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, &ref);
}
zval_ptr_dtor(&ref);
zval_ptr_dtor(&arg);
break;
}
case PHP_MODE_REFLECTION_EXT_INFO:
{
int len = (int)strlen(reflection_what);
char *lcname = zend_str_tolower_dup(reflection_what, len);
zend_module_entry *module;
if ((module = zend_hash_str_find_ptr(&module_registry, lcname, len)) == NULL) {
if (!strcmp(reflection_what, "main")) {
display_ini_entries(NULL);
} else {
zend_printf("Extension '%s' not present.\n", reflection_what);
exit_status = 1;
}
} else {
php_info_print_module(module);
}
efree(lcname);
break;
}
case PHP_MODE_SHOW_INI_CONFIG:
{
zend_printf("Configuration File (php.ini) Path: %s\n", PHP_CONFIG_FILE_PATH);
zend_printf("Loaded Configuration File: %s\n", php_ini_opened_path ? php_ini_opened_path : "(none)");
zend_printf("Scan for additional .ini files in: %s\n", php_ini_scanned_path ? php_ini_scanned_path : "(none)");
zend_printf("Additional .ini files parsed: %s\n", php_ini_scanned_files ? php_ini_scanned_files : "(none)");
break;
}
}
} zend_end_try();
out:
if (request_started) {
php_request_shutdown((void *) 0);
}
if (translated_path) {
free(translated_path);
}
if (exit_status == 0) {
exit_status = EG(exit_status);
}
return exit_status;
err:
sapi_deactivate();
zend_ini_deactivate();
exit_status = 1;
goto out;
}
开发者ID:EleTeam,项目名称:php-src,代码行数:101,代码来源:php_cli.c
示例18: request
bool ScriptEngine::checkSessionId(const std::string& sessionId)
{
if(_disposing) return false;
std::unique_ptr<BaseLib::HTTP> request(new BaseLib::HTTP());
ts_resource_ex(0, NULL); //Replaces TSRMLS_FETCH()
try
{
zend_homegear_globals* globals = php_homegear_get_globals();
if(!globals)
{
ts_free_thread();
return false;
}
globals->http = request.get();
if(!tsrm_get_ls_cache() || !((sapi_globals_struct *) (*((void ***) tsrm_get_ls_cache()))[((sapi_globals_id)-1)]))
{
GD::out.printCritical("Critical: Error in PHP: No thread safe resource exists.");
ts_free_thread();
return false;
}
SG(server_context) = (void*)request.get(); //Must be defined! Otherwise POST data is not processed.
SG(sapi_headers).http_response_code = 200;
SG(default_mimetype) = nullptr;
SG(default_charset) = nullptr;
SG(request_info).content_length = 0;
SG(request_info).request_method = "GET";
SG(request_info).proto_num = 1001;
request->getHeader()->cookie = "PHPSESSID=" + sessionId;
if (php_request_startup(TSRMLS_C) == FAILURE) {
GD::bl->out.printError("Error calling php_request_startup...");
ts_free_thread();
return false;
}
zval returnValue;
zval function;
ZVAL_STRING(&function, "session_start");
call_user_function(EG(function_table), NULL, &function, &returnValue, 0, nullptr);
bool result = false;
zval* reference = zend_hash_str_find(&EG(symbol_table), "_SESSION", sizeof("_SESSION") - 1);
if(reference != NULL)
{
if(Z_ISREF_P(reference) && Z_RES_P(reference)->ptr && Z_TYPE_P(Z_REFVAL_P(reference)) == IS_ARRAY)
{
zval* token = zend_hash_str_find(Z_ARRVAL_P(Z_REFVAL_P(reference)), "authorized", sizeof("authorized") - 1);
if(token != NULL)
{
result = (Z_TYPE_P(token) == IS_TRUE);
}
}
}
php_request_shutdown(NULL);
ts_free_thread();
return result;
}
catch(const std::exception& ex)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(BaseLib::Exception& ex)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(...)
{
GD::bl->out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
}
std::string error("Error executing script. Check Homegear log for more details.");
ts_free_thread();
return false;
}
开发者ID:pauxus,项目名称:Homegear,代码行数:77,代码来源:ScriptEngine.cpp
示例19: php_apache_request_dtor
static void php_apache_request_dtor(request_rec *r)
{
php_request_shutdown(NULL);
}
开发者ID:SammyK,项目名称:php-src,代码行数:4,代码来源:sapi_apache2.c
示例20: cli_main
static int cli_main( int argc, char * argv[] )
{
static const char * ini_defaults[] = {
"report_zend_debug", "0",
"display_errors", "1",
"register_argc_argv", "1",
"html_errors", "0",
"implicit_flush", "1",
"output_buffering", "0",
"max_execution_time", "0",
"max_input_time", "-1",
NULL
};
const char ** ini;
char ** p = &argv[1];
char ** argend= &argv[argc];
int ret = -1;
int c;
#if PHP_MAJOR_VERSION >= 7
zend_string * psKey;
#endif
lsapi_mode = 0; /* enter CLI mode */
#ifdef PHP_WIN32
_fmode = _O_BINARY; /*sets default for file streams to binary */
setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
#endif
zend_first_try {
SG(server_context) = (void *) 1;
zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */
CG(in_compilation) = 0; /* not initialized but needed for several options */
SG(options) |= SAPI_OPTION_NO_CHDIR;
#if PHP_MAJOR_VERSION < 7
EG(uninitialized_zval_ptr) = NULL;
#endif
for( ini = ini_defaults; *ini; ini+=2 ) {
#if PHP_MAJOR_VERSION >= 7
psKey = zend_string_init(*ini, strlen( *ini ), 1);
zend_alter_ini_entry_chars(psKey,
(char *)*(ini+1), strlen( *(ini+1) ),
PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
zend_string_release(psKey);
#else
zend_alter_ini_entry( (char *)*ini, strlen( *ini )+1,
(char *)*(ini+1), strlen( *(ini+1) ),
PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
#endif
}
while (( p < argend )&&(**p == '-' )) {
c = *((*p)+1);
++p;
switch( c ) {
case 'q':
break;
case 'i':
if (php_request_startup() != FAILURE) {
php_print_info(0xFFFFFFFF);
#ifdef PHP_OUTPUT_NEWAPI
php_output_end_all();
#else
php_end_ob_buffers(1);
#endif
php_request_shutdown( NULL );
ret = 0;
}
break;
case 'v':
if (php_request_startup() != FAILURE) {
#if ZEND_DEBUG
php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
#else
php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2018 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
#endif
#ifdef PHP_OUTPUT_NEWAPI
php_output_end_all();
#else
php_end_ob_buffers(1);
#endif
php_request_shutdown( NULL );
ret = 0;
}
break;
case 'c':
++p;
/* fall through */
case 's':
break;
case 'l':
source_highlight = 2;
break;
case 'h':
case '?':
//.........这里部分代码省略.........
开发者ID:RyanNerd,项目名称:php-src,代码行数:101,代码来源:lsapi_main.c
注:本文中的php_request_shutdown函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论