mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-08 01:37:30 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cbb4b61aa | ||
|
|
6726111972 |
No files matched your search
@@ -1,5 +0,0 @@
|
||||
|
||||
LTLIBRARY_NAME = libregex.la
|
||||
LTLIBRARY_SOURCES = regcomp.c regexec.c regerror.c regfree.c
|
||||
|
||||
include $(top_srcdir)/build/ltlib.mk
|
||||
@@ -0,0 +1,2 @@
|
||||
sqlite
|
||||
Wez Furlong
|
||||
File renamed without changes.
@@ -0,0 +1,45 @@
|
||||
dnl $Id$
|
||||
dnl config.m4 for extension sqlite
|
||||
|
||||
PHP_ARG_WITH(sqlite, for sqlite support,
|
||||
[ --with-sqlite Include sqlite support])
|
||||
|
||||
if test "$PHP_SQLITE" != "no"; then
|
||||
SEARCH_PATH="/usr/local /usr"
|
||||
SEARCH_FOR="/include/sqlite.h"
|
||||
if test -r $PHP_SQLITE/; then # path given as parameter
|
||||
SQLITE_DIR=$PHP_SQLITE
|
||||
else # search default path list
|
||||
AC_MSG_CHECKING([for sqlite files in default path])
|
||||
for i in $SEARCH_PATH ; do
|
||||
if test -r $i/$SEARCH_FOR; then
|
||||
SQLITE_DIR=$i
|
||||
AC_MSG_RESULT(found in $i)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -z "$SQLITE_DIR"; then
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please reinstall the sqlite distribution])
|
||||
fi
|
||||
|
||||
PHP_ADD_INCLUDE($SQLITE_DIR/include)
|
||||
|
||||
LIBNAME=sqlite
|
||||
LIBSYMBOL=sqlite_open
|
||||
|
||||
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
|
||||
[
|
||||
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $SQLITE_DIR/lib, SQLITE_SHARED_LIBADD)
|
||||
AC_DEFINE(HAVE_SQLITELIB,1,[ ])
|
||||
],[
|
||||
AC_MSG_ERROR([wrong sqlite lib version or lib not found])
|
||||
],[
|
||||
-L$SQLITE_DIR/lib -lm -ldl
|
||||
])
|
||||
|
||||
PHP_SUBST(SQLITE_SHARED_LIBADD)
|
||||
|
||||
PHP_NEW_EXTENSION(sqlite, sqlite.c, $ext_shared)
|
||||
fi
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef PHP_SQLITE_H
|
||||
#define PHP_SQLITE_H
|
||||
|
||||
extern zend_module_entry sqlite_module_entry;
|
||||
#define phpext_sqlite_ptr &sqlite_module_entry
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define PHP_SQLITE_API __declspec(dllexport)
|
||||
#else
|
||||
#define PHP_SQLITE_API
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
PHP_MINIT_FUNCTION(sqlite);
|
||||
PHP_MSHUTDOWN_FUNCTION(sqlite);
|
||||
PHP_RINIT_FUNCTION(sqlite);
|
||||
PHP_RSHUTDOWN_FUNCTION(sqlite);
|
||||
PHP_MINFO_FUNCTION(sqlite);
|
||||
|
||||
PHP_FUNCTION(sqlite_open);
|
||||
PHP_FUNCTION(sqlite_close);
|
||||
PHP_FUNCTION(sqlite_query);
|
||||
PHP_FUNCTION(sqlite_fetch_array);
|
||||
|
||||
PHP_FUNCTION(sqlite_num_rows);
|
||||
PHP_FUNCTION(sqlite_num_fields);
|
||||
PHP_FUNCTION(sqlite_field_name);
|
||||
PHP_FUNCTION(sqlite_seek);
|
||||
|
||||
PHP_FUNCTION(sqlite_libversion);
|
||||
PHP_FUNCTION(sqlite_libencoding);
|
||||
|
||||
PHP_FUNCTION(sqlite_changes);
|
||||
PHP_FUNCTION(sqlite_last_insert_rowid);
|
||||
|
||||
#ifdef ZTS
|
||||
#define SQLITE_G(v) TSRMG(sqlite_globals_id, zend_sqlite_globals *, v)
|
||||
#else
|
||||
#define SQLITE_G(v) (sqlite_globals.v)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Wez Furlong <wez@thebrainroom.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_ini.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "php_sqlite.h"
|
||||
|
||||
#include <sqlite.h>
|
||||
|
||||
static unsigned char arg3_force_ref[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
|
||||
|
||||
static int le_sqlite_db, le_sqlite_result;
|
||||
|
||||
struct php_sqlite_result {
|
||||
char **table;
|
||||
int nrows;
|
||||
int ncolumns;
|
||||
int curr_row;
|
||||
};
|
||||
|
||||
enum { PHPSQLITE_ASSOC = 1, PHPSQLITE_NUM = 2, PHPSQLITE_BOTH = PHPSQLITE_ASSOC|PHPSQLITE_NUM };
|
||||
|
||||
function_entry sqlite_functions[] = {
|
||||
PHP_FE(sqlite_open, arg3_force_ref)
|
||||
PHP_FE(sqlite_close, NULL)
|
||||
PHP_FE(sqlite_query, NULL)
|
||||
PHP_FE(sqlite_fetch_array, NULL)
|
||||
PHP_FE(sqlite_libversion, NULL)
|
||||
PHP_FE(sqlite_libencoding, NULL)
|
||||
PHP_FE(sqlite_changes, NULL)
|
||||
PHP_FE(sqlite_last_insert_rowid, NULL)
|
||||
PHP_FE(sqlite_num_rows, NULL)
|
||||
PHP_FE(sqlite_num_fields, NULL)
|
||||
PHP_FE(sqlite_field_name, NULL)
|
||||
PHP_FE(sqlite_seek, NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
zend_module_entry sqlite_module_entry = {
|
||||
#if ZEND_MODULE_API_NO >= 20010901
|
||||
STANDARD_MODULE_HEADER,
|
||||
#endif
|
||||
"sqlite",
|
||||
sqlite_functions,
|
||||
PHP_MINIT(sqlite),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(sqlite),
|
||||
#if ZEND_MODULE_API_NO >= 20010901
|
||||
"0.1",
|
||||
#endif
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
|
||||
#ifdef COMPILE_DL_SQLITE
|
||||
ZEND_GET_MODULE(sqlite)
|
||||
#endif
|
||||
|
||||
|
||||
static ZEND_RSRC_DTOR_FUNC(php_sqlite_db_dtor)
|
||||
{
|
||||
sqlite *db = (sqlite*)rsrc->ptr;
|
||||
|
||||
sqlite_close(db);
|
||||
}
|
||||
|
||||
static ZEND_RSRC_DTOR_FUNC(php_sqlite_result_dtor)
|
||||
{
|
||||
struct php_sqlite_result *res = (struct php_sqlite_result *)rsrc->ptr;
|
||||
|
||||
sqlite_free_table(res->table);
|
||||
efree(res);
|
||||
}
|
||||
|
||||
PHP_MINIT_FUNCTION(sqlite)
|
||||
{
|
||||
le_sqlite_db = zend_register_list_destructors_ex(php_sqlite_db_dtor, NULL, "sqlite database", module_number);
|
||||
le_sqlite_result = zend_register_list_destructors_ex(php_sqlite_result_dtor, NULL, "sqlite result", module_number);
|
||||
|
||||
REGISTER_LONG_CONSTANT("SQLITE_BOTH", PHPSQLITE_BOTH, CONST_CS|CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("SQLITE_NUM", PHPSQLITE_NUM, CONST_CS|CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("SQLITE_ASSOC", PHPSQLITE_ASSOC, CONST_CS|CONST_PERSISTENT);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MINFO_FUNCTION(sqlite)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "SQLite support", "enabled");
|
||||
php_info_print_table_row(2, "PECL Module version", "$Id$");
|
||||
php_info_print_table_row(2, "SQLite Library", sqlite_libversion());
|
||||
php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding());
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
/* {{{ proto resource sqlite_open(string filename [, int mode, string &errmessage])
|
||||
Opens an SQLite database. Will create the database if it does not exist */
|
||||
PHP_FUNCTION(sqlite_open)
|
||||
{
|
||||
int mode = 0666;
|
||||
char *filename;
|
||||
long filename_len;
|
||||
zval *errmsg = NULL;
|
||||
sqlite *db = NULL;
|
||||
char *errtext = NULL;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
|
||||
&filename, &filename_len, &mode, &errmsg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: safemode and open_basedir checks on the filename */
|
||||
|
||||
db = sqlite_open(filename, mode, &errtext);
|
||||
|
||||
if (db == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
|
||||
|
||||
if (errmsg) {
|
||||
ZVAL_STRING(errmsg, errtext, 1);
|
||||
}
|
||||
|
||||
sqlite_freemem(errtext);
|
||||
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, db, le_sqlite_db);
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto void sqlite_close(resource db)
|
||||
Closes an open sqlite database */
|
||||
PHP_FUNCTION(sqlite_close)
|
||||
{
|
||||
zval *zdb;
|
||||
sqlite *db;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zdb)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(db, sqlite *, &zdb, -1, "sqlite database", le_sqlite_db);
|
||||
zend_list_delete(Z_RESVAL_P(zdb));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto resource sqlite_query(string query, resource db)
|
||||
Executes a query against a given database and returns a result handle */
|
||||
PHP_FUNCTION(sqlite_query)
|
||||
{
|
||||
zval *zdb;
|
||||
sqlite *db;
|
||||
char *sql;
|
||||
long sql_len;
|
||||
struct php_sqlite_result res, *rres;
|
||||
int ret;
|
||||
char *errtext;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sr", &sql, &sql_len, &zdb)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(db, sqlite *, &zdb, -1, "sqlite database", le_sqlite_db);
|
||||
|
||||
memset(&res, 0, sizeof(res));
|
||||
|
||||
ret = sqlite_get_table(db, sql, &res.table, &res.nrows, &res.ncolumns, &errtext);
|
||||
|
||||
if (ret != SQLITE_OK) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
|
||||
sqlite_freemem(errtext);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
rres = (struct php_sqlite_result*)emalloc(sizeof(*rres));
|
||||
memcpy(rres, &res, sizeof(*rres));
|
||||
|
||||
rres->curr_row = 1; /* 0 holds the column header names */
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, rres, le_sqlite_result);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array sqlite_fetch_array(resource result [, int result_type])
|
||||
Fetches the next row from a result set as an array */
|
||||
PHP_FUNCTION(sqlite_fetch_array)
|
||||
{
|
||||
zval *zres;
|
||||
struct php_sqlite_result *res;
|
||||
int mode = PHPSQLITE_BOTH;
|
||||
int i, j;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zres, &mode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
|
||||
|
||||
/* check range of the row */
|
||||
if (res->curr_row > res->nrows) {
|
||||
/* no more */
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
/* calculate the starting slot for the row */
|
||||
i = res->curr_row * res->ncolumns;
|
||||
|
||||
/* now populate the result */
|
||||
for (j = 0; j < res->ncolumns; j++) {
|
||||
if (mode & PHPSQLITE_NUM) {
|
||||
add_index_string(return_value, j, res->table[i + j], 1);
|
||||
}
|
||||
if (mode & PHPSQLITE_ASSOC) {
|
||||
add_assoc_string(return_value, res->table[j], res->table[i + j], 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* advance the row pointer */
|
||||
res->curr_row++;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string sqlite_libversion()
|
||||
Returns the version of the linked SQLite library */
|
||||
PHP_FUNCTION(sqlite_libversion)
|
||||
{
|
||||
if (ZEND_NUM_ARGS() != 0) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
RETURN_STRING((char*)sqlite_libversion(), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string sqlite_libencoding()
|
||||
Returns the encoding (iso8859 or UTF-8) of the linked SQLite library */
|
||||
PHP_FUNCTION(sqlite_libencoding)
|
||||
{
|
||||
if (ZEND_NUM_ARGS() != 0) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
RETURN_STRING((char*)sqlite_libencoding(), 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int sqlite_changes(resource db)
|
||||
Returns the number of rows that were changed by the most recent SQL statement */
|
||||
PHP_FUNCTION(sqlite_changes)
|
||||
{
|
||||
zval *zdb;
|
||||
sqlite *db;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zdb)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(db, sqlite *, &zdb, -1, "sqlite database", le_sqlite_db);
|
||||
|
||||
RETURN_LONG(sqlite_changes(db));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int sqlite_last_insert_rowid(resource db)
|
||||
Returns the rowid of the most recently inserted row */
|
||||
PHP_FUNCTION(sqlite_last_insert_rowid)
|
||||
{
|
||||
zval *zdb;
|
||||
sqlite *db;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zdb)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(db, sqlite *, &zdb, -1, "sqlite database", le_sqlite_db);
|
||||
|
||||
RETURN_LONG(sqlite_last_insert_rowid(db));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int sqlite_num_rows(resource result)
|
||||
Returns the number of rows in a result set */
|
||||
PHP_FUNCTION(sqlite_num_rows)
|
||||
{
|
||||
zval *zres;
|
||||
struct php_sqlite_result *res;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
|
||||
|
||||
RETURN_LONG(res->nrows);
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int sqlite_num_fields(resource result)
|
||||
Returns the number of fields in a result set */
|
||||
PHP_FUNCTION(sqlite_num_fields)
|
||||
{
|
||||
zval *zres;
|
||||
struct php_sqlite_result *res;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
|
||||
|
||||
RETURN_LONG(res->ncolumns);
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string sqlite_field_name(resource result, int field)
|
||||
Returns the name of a particular field */
|
||||
PHP_FUNCTION(sqlite_field_name)
|
||||
{
|
||||
zval *zres;
|
||||
struct php_sqlite_result *res;
|
||||
int field;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zres, &field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
|
||||
|
||||
if (field < 0 || field >= res->ncolumns) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "field %d out of range", field);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_STRING(res->table[field], 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool sqlite_seek(resource result, int row)
|
||||
Seek to a particular row number */
|
||||
PHP_FUNCTION(sqlite_seek)
|
||||
{
|
||||
zval *zres;
|
||||
struct php_sqlite_result *res;
|
||||
int row;
|
||||
|
||||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zres, &row)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
|
||||
|
||||
if (row < 1 || row >= res->nrows) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "row %d out of range", row);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
res->curr_row = row;
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
dl("sqlite.so");
|
||||
|
||||
debug_zval_dump(sqlite_libversion());
|
||||
debug_zval_dump(sqlite_libencoding());
|
||||
|
||||
$s = sqlite_open("weztest.sqlite", 0666, $err);
|
||||
|
||||
debug_zval_dump($err);
|
||||
debug_zval_dump($s);
|
||||
|
||||
$r = sqlite_query("create table foo (a INTEGER PRIMARY KEY, b INTEGER )", $s);
|
||||
$r = sqlite_query("select * from sqlite_master", $s);
|
||||
debug_zval_dump($r);
|
||||
debug_zval_dump(sqlite_num_rows($r));
|
||||
debug_zval_dump(sqlite_num_fields($r));
|
||||
|
||||
for ($j = 0; $j < sqlite_num_fields($r); $j++) {
|
||||
echo "Field $j is " . sqlite_field_name($r, $j) . "\n";
|
||||
}
|
||||
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_ASSOC)) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
sqlite_close($s);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
Check for sqlite presence
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--INI--
|
||||
--FILE--
|
||||
<?php
|
||||
echo "sqlite extension is available";
|
||||
/*
|
||||
you can add regression tests for your extension here
|
||||
|
||||
the output of your test code has to be equal to the
|
||||
text in the --EXPECT-- section below for the tests
|
||||
to pass, differences between the output and the
|
||||
expected text are interpreted as failure
|
||||
|
||||
see php4/README.TESTING for further information on
|
||||
writing regression tests
|
||||
*/
|
||||
?>
|
||||
--EXPECT--
|
||||
sqlite extension is available
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
LTLIBRARY_NAME = libregex.la
|
||||
LTLIBRARY_SOURCES = regcomp.c regexec.c regerror.c regfree.c
|
||||
|
||||
include $(top_srcdir)/build/ltlib.mk
|
||||
@@ -1,142 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="php4apache2" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=php4apache2 - Win32 Debug_TS
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "php4apache2.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "php4apache2.mak" CFG="php4apache2 - Win32 Debug_TS"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "php4apache2 - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "php4apache2 - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "php4apache2 - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "php4apache2 - Win32 Release_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release_TS"
|
||||
# PROP BASE Intermediate_Dir "Release_TS"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_TS"
|
||||
# PROP Intermediate_Dir "Release_TS"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4APACHE2_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "_WINSOCK2API_" /D "_MSWSOCK_" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
# ADD RSC /l 0x407 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 php4ts.lib libhttpd.lib libapr.lib libaprutil.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS"
|
||||
|
||||
!ELSEIF "$(CFG)" == "php4apache2 - Win32 Release_TS_inline"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release_TS_inline"
|
||||
# PROP BASE Intermediate_Dir "Release_TS_inline"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_TS_inline"
|
||||
# PROP Intermediate_Dir "Release_TS_inline"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4APACHE2_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "_WINSOCK2API_" /D "_MSWSOCK_" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "NDEBUG"
|
||||
# ADD RSC /l 0x407 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 php4ts.lib libhttpd.lib libapr.lib libaprutil.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS_inline/php4apache2.dll" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline"
|
||||
|
||||
!ELSEIF "$(CFG)" == "php4apache2 - Win32 Debug_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug_TS"
|
||||
# PROP BASE Intermediate_Dir "Debug_TS"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug_TS"
|
||||
# PROP Intermediate_Dir "Debug_TS"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4APACHE2_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "_WINSOCK2API_" /D "_MSWSOCK_" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x407 /d "_DEBUG"
|
||||
# ADD RSC /l 0x407 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 php4ts.lib libhttpd.lib libapr.lib libaprutil.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "php4apache2 - Win32 Release_TS"
|
||||
# Name "php4apache2 - Win32 Release_TS_inline"
|
||||
# Name "php4apache2 - Win32 Debug_TS"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\apache_config.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\php_functions.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sapi_apache2.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\php_apache.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,99 +0,0 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
AC_DEFUN(PHP_TEST_WRITE_STDOUT,[
|
||||
AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
|
||||
AC_TRY_RUN([
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define TEXT "This is the test message -- "
|
||||
|
||||
main()
|
||||
{
|
||||
int n;
|
||||
|
||||
n = write(1, TEXT, sizeof(TEXT)-1);
|
||||
return (!(n == sizeof(TEXT)-1));
|
||||
}
|
||||
],[
|
||||
ac_cv_write_stdout=yes
|
||||
],[
|
||||
ac_cv_write_stdout=no
|
||||
],[
|
||||
ac_cv_write_stdout=no
|
||||
])
|
||||
])
|
||||
if test "$ac_cv_write_stdout" = "yes"; then
|
||||
AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
|
||||
fi
|
||||
])
|
||||
|
||||
if test "$PHP_SAPI" = "default"; then
|
||||
|
||||
PHP_TEST_WRITE_STDOUT
|
||||
|
||||
PHP_ARG_ENABLE(force-cgi-redirect,whether to force Apache CGI redirect,
|
||||
[ --enable-force-cgi-redirect
|
||||
Enable the security check for internal server
|
||||
redirects. You should use this if you are
|
||||
running the CGI version with Apache. ])
|
||||
|
||||
if test "$PHP_FORCE_CGI_REDIRECT" = "yes"; then
|
||||
REDIRECT=1
|
||||
else
|
||||
REDIRECT=0
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(FORCE_CGI_REDIRECT,$REDIRECT,[ ])
|
||||
|
||||
PHP_ARG_ENABLE(discard-path,whether to discard path_info + path_translated,
|
||||
[ --enable-discard-path If this is enabled, the PHP CGI binary
|
||||
can safely be placed outside of the
|
||||
web tree and people will not be able
|
||||
to circumvent .htaccess security. ])
|
||||
|
||||
if test "$PHP_DISCARD_PATH" = "yes"; then
|
||||
DISCARD_PATH=1
|
||||
else
|
||||
DISCARD_PATH=0
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(DISCARD_PATH, $DISCARD_PATH, [ ])
|
||||
|
||||
INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_PROGRAM \$(INSTALL_ROOT)\$(bindir)/php-cgi"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for fhttpd module support)
|
||||
AC_ARG_WITH(fhttpd,
|
||||
[ --with-fhttpd[=DIR] Build fhttpd module. DIR is the fhttpd sources
|
||||
directory, defaults to /usr/local/src/fhttpd.],
|
||||
[
|
||||
if test "$withval" = "yes"; then
|
||||
# fhttpd source directory
|
||||
withval=/usr/local/src/fhttpd
|
||||
fi
|
||||
if test "$withval" != "no"; then
|
||||
# For fhttpd 0.3.x
|
||||
if test -f $withval/servproc.h; then
|
||||
FHTTPD_INCLUDE=-I$withval/
|
||||
FHTTPD_LIB=$withval/servproc.o
|
||||
FHTTPD_TARGET=$withval/
|
||||
PHP_BUILD_STATIC
|
||||
PHP_SAPI=cgi
|
||||
AC_DEFINE(FHTTPD,1,[ ])
|
||||
AC_MSG_RESULT(yes - fhttpd 0.3.x)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR(Invalid fhttpd directory - unable to find servproc.h under $withval)
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
INCLUDES="$INCLUDES $FHTTPD_INCLUDE"
|
||||
dnl## AC_SUBST(FHTTPD_INCLUDE)
|
||||
PHP_SUBST(FHTTPD_LIB)
|
||||
PHP_SUBST(FHTTPD_TARGET)
|
||||
@@ -1,4 +0,0 @@
|
||||
fastcgi
|
||||
Ben Mansell
|
||||
Stephen Landamore
|
||||
Daniel Silverstone
|
||||
@@ -1,53 +0,0 @@
|
||||
Using FastCGI PHP with Apache
|
||||
=============================
|
||||
|
||||
First of all, you may well ask 'Why?'. After all, Apache already has mod_php.
|
||||
However, there are advantages to running PHP with FastCGI. Separating the
|
||||
PHP code from the web server removes 'bloat' from the main server, and should
|
||||
improve the performance of non-PHP requests. Secondly, having one permanent
|
||||
PHP process as opposed to one per apache process means that shared resources
|
||||
like persistent database connections are used more efficiently.
|
||||
|
||||
First of all, make sure that the FastCGI module is enabled. You should have
|
||||
a line in your config like:
|
||||
|
||||
LoadModule fastcgi_module /usr/lib/apache/1.3/mod_fastcgi.so
|
||||
|
||||
Don't load mod_php, by the way. Make sure it is commented out!
|
||||
|
||||
#LoadModule php4_module /usr/lib/apache/1.3/libphp4.so
|
||||
|
||||
Now, we'll create a fcgi-bin directory, just like you would do with normal
|
||||
CGI scripts. You'll need to create a directory somewhere to store your
|
||||
FastCGI binaries. We'll use /space/fcgi-bin/ for this example. Remember to
|
||||
copy the FastCGI-PHP binary in there. (named just 'php')
|
||||
|
||||
ScriptAlias /fcgi-bin/ /space/fcgi-bin/
|
||||
<Location /fcgi-bin/>
|
||||
SetHandler fastcgi-script
|
||||
</Location>
|
||||
|
||||
Next, we need to tell Apache to use the FastCGI binary /fcgi-bin/php to
|
||||
deliver PHP pages. All that is needed is:
|
||||
|
||||
AddType application/x-httpd-php .php
|
||||
Action application/x-httpd-php /fcgi-bin/php
|
||||
|
||||
Now, if you restart Apache, php pages should now be delivered!
|
||||
|
||||
|
||||
Running PHP-FastCGI separately from the webserver
|
||||
-------------------------------------------------
|
||||
|
||||
(Read README.FastCGI for why you might want to do this).
|
||||
Easy! Add one more configuration line:
|
||||
|
||||
FastCgiExternalServer /space/fcgi-bin/php -host localhost:8002
|
||||
|
||||
Then, start the PHP off with the following command:
|
||||
|
||||
/space/fcgi-bin/php 8002
|
||||
|
||||
The number 8002 is the port that PHP will listen on for requests - change this
|
||||
to anything suitable. And be sure to firewall it out so that external
|
||||
connections are denied!
|
||||
@@ -1,91 +0,0 @@
|
||||
FastCGI module
|
||||
--------------
|
||||
|
||||
This module requires the FastCGI development kit, available from
|
||||
http://www.fastcgi.com/
|
||||
|
||||
Before building PHP, please enter the dev kit, and run:
|
||||
|
||||
./configure
|
||||
make
|
||||
make export
|
||||
|
||||
This will compile the library code required for the FastCGI module. All
|
||||
that is then required is to configure PHP with the '--with-fastcgi' option.
|
||||
After making the code, you will end up with a binary file called 'php'.
|
||||
Installation of this file will depend on the web server being used, please
|
||||
see their documentation for details.
|
||||
|
||||
|
||||
|
||||
Running the FastCGI PHP module
|
||||
------------------------------
|
||||
|
||||
There are two ways to run the resulting 'php' binary after the fastcgi
|
||||
version has been built:
|
||||
|
||||
1) Configure your web server to run the PHP binary itself.
|
||||
|
||||
This is the simplest method, obviously you will have to configure your
|
||||
web server appropriately. Some web servers may also not support this method,
|
||||
or may not be as efficient.
|
||||
|
||||
2) Run PHP separately from the web server.
|
||||
|
||||
In this setup, PHP is started as a separate process entirely from the web
|
||||
server. It will listen on a socket for new FastCGI requests, and deliver
|
||||
PHP pages as appropriate. This is the recommended way of running PHP-FastCGI.
|
||||
To run this way, you must start the PHP binary running by giving it a port
|
||||
number to listen to on the command line, e.g.:
|
||||
|
||||
./php 8002
|
||||
|
||||
(you can also specify a bind address, e.g. ./php localhost:8002. However, this
|
||||
relies on the FastCGI devkit and does not seem to work properly)
|
||||
|
||||
You must also configure your web server to connect to the appropriate port
|
||||
in order to talk to the PHP FastCGI process.
|
||||
|
||||
The advantage of running PHP in this way is that it entirely separates the
|
||||
web server and PHP process, so that one cannot disrupt the other. It also
|
||||
allows PHP to be on an entirely separate machine from the web server if need
|
||||
be, you could even have several web servers utilising the same running PHP
|
||||
process if required!
|
||||
|
||||
|
||||
Security
|
||||
--------
|
||||
|
||||
Be sure to run the php binary as an appropriate userid. Also, firewall out
|
||||
the port that PHP is listening on. In addition, you can set the environment
|
||||
variable FCGI_WEB_SERVER_ADDRS to control who can connect to the FastCGI.
|
||||
Set it to a comma separated list of IP addresses, e.g.:
|
||||
|
||||
export FCGI_WEB_SERVER_ADDRS=199.170.183.28,199.170.183.71
|
||||
|
||||
|
||||
Tuning
|
||||
------
|
||||
|
||||
There are a few tuning parameters that can be tweaked to control the
|
||||
performance of FastCGI PHP. The following are environment variables that can
|
||||
be set before running the PHP binary:
|
||||
|
||||
PHP_FCGI_CHILDREN (default value: 8)
|
||||
|
||||
This controls how many child processes the PHP process spawns. When the
|
||||
fastcgi starts, it creates a number of child processes which handle one
|
||||
page request at a time. So by default, you will be able to handle 8
|
||||
concurrent PHP page requests. Further requests will be queued.
|
||||
Increasing this number will allow for better concurrency, especially if you
|
||||
have pages that take a significant time to create, or supply a lot of data
|
||||
(e.g. downloading huge files via PHP). On the other hand, having more
|
||||
processes running will use more RAM, and letting too many PHP pages be
|
||||
generated concurrently will mean that each request will be slow.
|
||||
|
||||
PHP_FCGI_MAX_REQUESTS (default value: 500)
|
||||
|
||||
This controls how many requests each child process will handle before
|
||||
exitting. When one process exits, another will be created. This tuning is
|
||||
necessary because several PHP functions are known to have memory leaks. If the
|
||||
PHP processes were left around forever, they would be become very inefficient.
|
||||
@@ -1,26 +0,0 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl
|
||||
|
||||
AC_MSG_CHECKING(for FastCGI support)
|
||||
AC_ARG_WITH(fastcgi,
|
||||
[ --with-fastcgi=SRCDIR Build PHP as FastCGI application],[
|
||||
if test "$withval" = "yes"; then
|
||||
FASTCGIPATH=/usr/local
|
||||
else
|
||||
FASTCGIPATH=$withval
|
||||
fi
|
||||
test -f "$FASTCGIPATH/lib/libfcgi.a" || AC_MSG_ERROR(Unable to find libfcgi.a in $FASTCGIPATH/lib)
|
||||
test -f "$FASTCGIPATH/include/fastcgi.h" || AC_MSG_ERROR(Unable to find fastcgi.h in $FASTCGIPATH/include)
|
||||
PHP_SELECT_SAPI(fastcgi, programm, fastcgi.c)
|
||||
PHP_LIBS=$FASTCGIPATH/lib/libfcgi.a
|
||||
PHP_ADD_INCLUDE($FASTCGIPATH/include)
|
||||
EXT_PROGRAM_LDADD="$EXT_PROGRAM_LDADD $FASTCGIPATH/lib/libfcgi.a"
|
||||
INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_PROGRAM \$(bindir)/$SAPI_FASTCGI"
|
||||
RESULT=yes
|
||||
PHP_SUBST(FASTCGI_LIBADD)
|
||||
PHP_SUBST(EXT_PROGRAM_LDADD)
|
||||
],[
|
||||
RESULT=no
|
||||
])
|
||||
AC_MSG_RESULT($RESULT)
|
||||
@@ -1,609 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Ben Mansell <php@slimyhorror.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* Debugging */
|
||||
/* #define DEBUG_FASTCGI 1 */
|
||||
|
||||
/* Two configurables for the FastCGI runner.
|
||||
*
|
||||
* PHP_FCGI_CHILDREN - if set, the FastCGI will pre-fork this many processes
|
||||
* which will accept requests.
|
||||
*
|
||||
* PHP_FCGI_MAX_REQUESTS - if set, the runner will kill itself after handling
|
||||
* the given number of requests. This is to curb any
|
||||
* memory leaks in PHP.
|
||||
*/
|
||||
|
||||
|
||||
/* The following code is based mainly on the thttpd sapi and the original
|
||||
* CGI code, no doubt with many new and interesting bugs created... :)
|
||||
*/
|
||||
|
||||
#include "php.h"
|
||||
#include "SAPI.h"
|
||||
#include "php_main.h"
|
||||
#include "php_fastcgi.h"
|
||||
#include "php_variables.h"
|
||||
|
||||
#include "fcgi_config.h"
|
||||
#include "fcgiapp.h"
|
||||
#include <stdio.h>
|
||||
#if HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef PHP_WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include "win32/php_registry.h"
|
||||
#else
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#if HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(mode) ((mode) & _S_IFREG)
|
||||
#endif
|
||||
|
||||
FCGX_Stream *in, *out, *err;
|
||||
FCGX_ParamArray envp;
|
||||
char *path_info = NULL;
|
||||
#ifndef PHP_WIN32
|
||||
struct sigaction act, old_term, old_quit, old_int;
|
||||
#endif
|
||||
|
||||
/* Our original environment from when the FastCGI first started */
|
||||
char **orig_env;
|
||||
|
||||
/* The environment given by the FastCGI */
|
||||
char **cgi_env;
|
||||
|
||||
/* The manufactured environment, from merging the base environ with
|
||||
* the parameters set by the per-connection environment
|
||||
*/
|
||||
char **merge_env;
|
||||
|
||||
/**
|
||||
* Number of child processes that will get created to service requests
|
||||
*/
|
||||
static int children = 8;
|
||||
|
||||
/**
|
||||
* Set to non-zero if we are the parent process
|
||||
*/
|
||||
static int parent = 1;
|
||||
|
||||
/**
|
||||
* Process group
|
||||
*/
|
||||
static pid_t pgroup;
|
||||
|
||||
|
||||
static int sapi_fastcgi_ub_write(const char *str, uint str_length TSRMLS_DC)
|
||||
{
|
||||
uint sent = FCGX_PutStr( str, str_length, out );
|
||||
return sent;
|
||||
}
|
||||
|
||||
|
||||
static void sapi_fastcgi_flush( void *server_context )
|
||||
{
|
||||
if( FCGX_FFlush( out ) == -1 ) {
|
||||
php_handle_aborted_connection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void sapi_fastcgi_send_header(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC)
|
||||
{
|
||||
if( sapi_header ) {
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Header: %s\n", sapi_header->header );
|
||||
#endif
|
||||
FCGX_PutStr( sapi_header->header, sapi_header->header_len, out );
|
||||
}
|
||||
FCGX_PutStr( "\r\n", 2, out );
|
||||
}
|
||||
|
||||
static int sapi_fastcgi_read_post(char *buffer, uint count_bytes TSRMLS_DC)
|
||||
{
|
||||
size_t read_bytes = 0;
|
||||
int c;
|
||||
char *pos = buffer;
|
||||
|
||||
while( count_bytes ) {
|
||||
c = FCGX_GetStr( pos, count_bytes, in );
|
||||
read_bytes += c;
|
||||
count_bytes -= c;
|
||||
pos += c;
|
||||
if( !c ) break;
|
||||
}
|
||||
return read_bytes;
|
||||
}
|
||||
|
||||
static char *sapi_fastcgi_read_cookies(TSRMLS_D)
|
||||
{
|
||||
return getenv( "HTTP_COOKIE" );
|
||||
}
|
||||
|
||||
|
||||
static void sapi_fastcgi_register_variables(zval *track_vars_array TSRMLS_DC)
|
||||
{
|
||||
/* In CGI mode, we consider the environment to be a part of the server
|
||||
* variables
|
||||
*/
|
||||
php_import_environment_variables(track_vars_array TSRMLS_CC);
|
||||
|
||||
/* Build the special-case PHP_SELF variable for the CGI version */
|
||||
php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
static void sapi_fastcgi_log_message(char *message)
|
||||
{
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Log Message: %s\n", message );
|
||||
#endif
|
||||
FCGX_FPrintF(err, "%s\n", message);
|
||||
}
|
||||
|
||||
|
||||
static sapi_module_struct fastcgi_sapi_module = {
|
||||
"fastcgi",
|
||||
"FastCGI",
|
||||
|
||||
php_module_startup,
|
||||
php_module_shutdown_wrapper,
|
||||
|
||||
NULL, /* activate */
|
||||
NULL, /* deactivate */
|
||||
|
||||
sapi_fastcgi_ub_write,
|
||||
sapi_fastcgi_flush,
|
||||
NULL, /* get uid */
|
||||
NULL, /* getenv */
|
||||
|
||||
php_error,
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
sapi_fastcgi_send_header,
|
||||
sapi_fastcgi_read_post,
|
||||
sapi_fastcgi_read_cookies,
|
||||
|
||||
sapi_fastcgi_register_variables,
|
||||
sapi_fastcgi_log_message,
|
||||
|
||||
NULL, /* Block interruptions */
|
||||
NULL, /* Unblock interruptions */
|
||||
|
||||
STANDARD_SAPI_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
static void fastcgi_module_main(TSRMLS_D)
|
||||
{
|
||||
zend_file_handle file_handle;
|
||||
int c, retval = 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;
|
||||
|
||||
/* eat the bang line */
|
||||
if (SG(request_info).path_translated) {
|
||||
retval = php_fopen_primary_script(&file_handle TSRMLS_CC);
|
||||
}
|
||||
|
||||
if (retval == SUCCESS) {
|
||||
/* #!php support */
|
||||
c = fgetc(file_handle.handle.fp);
|
||||
if (c == '#') {
|
||||
while (c != 10 && c != 13) {
|
||||
c = fgetc(file_handle.handle.fp); /* skip to end of line */
|
||||
}
|
||||
CG(zend_lineno)++;
|
||||
} else {
|
||||
rewind(file_handle.handle.fp);
|
||||
}
|
||||
}
|
||||
|
||||
if (php_request_startup(TSRMLS_C) == SUCCESS) {
|
||||
php_execute_script(&file_handle TSRMLS_CC);
|
||||
php_request_shutdown(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int init_request_info( TSRMLS_D )
|
||||
{
|
||||
char *content_length = getenv("CONTENT_LENGTH");
|
||||
char *content_type = getenv( "CONTENT_TYPE" );
|
||||
const char *auth;
|
||||
struct stat st;
|
||||
char *pi = getenv( "PATH_INFO" );
|
||||
char *pt = getenv( "PATH_TRANSLATED" );
|
||||
if (!pt) {
|
||||
pt = getenv("SCRIPT_FILENAME"); // apache mod_fastcgi sets this
|
||||
}
|
||||
path_info = strdup( pi );
|
||||
|
||||
SG(request_info).request_method = getenv("REQUEST_METHOD");
|
||||
SG(request_info).query_string = getenv("QUERY_STRING");
|
||||
SG(request_info).request_uri = path_info;
|
||||
if (!SG(request_info).request_uri) {
|
||||
SG(request_info).request_uri = getenv("SCRIPT_NAME");
|
||||
}
|
||||
SG(request_info).content_type = ( content_type ? content_type : "" );
|
||||
SG(request_info).content_length = (content_length?atoi(content_length):0);
|
||||
SG(sapi_headers).http_response_code = 200;
|
||||
|
||||
SG(request_info).path_translated = pt;
|
||||
if (!pt) return -1;
|
||||
/*
|
||||
* if the file doesn't exist, try to extract PATH_INFO out
|
||||
* of it by stat'ing back through the '/'
|
||||
*/
|
||||
if ( stat( pt, &st ) == -1 ) {
|
||||
int len = strlen(pt);
|
||||
char *ptr;
|
||||
while( ptr = strrchr(pt,'/') ) {
|
||||
*ptr = 0;
|
||||
if ( stat(pt, &st) == 0 && S_ISREG(st.st_mode) ) {
|
||||
/*
|
||||
* okay, we found the base script!
|
||||
* work out how many chars we had to strip off;
|
||||
* then we can modify PATH_INFO
|
||||
* accordingly
|
||||
*/
|
||||
int slen = len - strlen(pt);
|
||||
if ( pi ) {
|
||||
int pilen = strlen( pi );
|
||||
strcpy( pi, pi + pilen - slen );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if we stripped out all the '/' and still didn't find
|
||||
* a valid path... we will fail, badly. of course we would
|
||||
* have failed anyway... is there a nice way to error?
|
||||
*/
|
||||
} else {
|
||||
/* the first stat succeeded... */
|
||||
if ( pi ) *pi = 0;
|
||||
}
|
||||
|
||||
/* The CGI RFC allows servers to pass on unvalidated Authorization data */
|
||||
auth = getenv("HTTP_AUTHORIZATION");
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Authorization: %s\n", auth );
|
||||
#endif
|
||||
php_handle_auth_data(auth TSRMLS_CC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void fastcgi_php_init(void)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
sapi_startup(&fastcgi_sapi_module);
|
||||
fastcgi_sapi_module.startup(&fastcgi_sapi_module);
|
||||
SG(server_context) = (void *) 1;
|
||||
}
|
||||
|
||||
void fastcgi_php_shutdown(void)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
if (SG(server_context) != NULL) {
|
||||
fastcgi_sapi_module.shutdown(&fastcgi_sapi_module);
|
||||
sapi_shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clean up child processes upon exit
|
||||
*/
|
||||
void fastcgi_cleanup(int signal)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "FastCGI shutdown, pid %d\n", getpid() );
|
||||
#endif
|
||||
|
||||
#ifndef PHP_WIN32
|
||||
sigaction( SIGTERM, &old_term, 0 );
|
||||
|
||||
/* Kill all the processes in our process group */
|
||||
kill( -pgroup, SIGTERM );
|
||||
#endif
|
||||
|
||||
/* We should exit at this point, but MacOSX doesn't seem to */
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int exit_status = SUCCESS;
|
||||
#ifndef PHP_WIN32
|
||||
int c, i, len;
|
||||
zend_file_handle file_handle;
|
||||
char *s;
|
||||
int status;
|
||||
#endif
|
||||
char *argv0=NULL;
|
||||
char *script_file=NULL;
|
||||
zend_llist global_vars;
|
||||
int max_requests = 500;
|
||||
int requests = 0;
|
||||
int fcgi_fd = 0;
|
||||
int env_size, cgi_env_size;
|
||||
FCGX_Request request;
|
||||
#ifdef ZTS
|
||||
zend_compiler_globals *compiler_globals;
|
||||
zend_executor_globals *executor_globals;
|
||||
php_core_globals *core_globals;
|
||||
sapi_globals_struct *sapi_globals;
|
||||
void ***tsrm_ls;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Initialising now, pid %d!\n", getpid() );
|
||||
#endif
|
||||
|
||||
if( FCGX_IsCGI() ) {
|
||||
/* Did a bind address or port get configured on the command line? */
|
||||
if( argc >= 2 ) {
|
||||
/* Pass on the arg to the FastCGI library, with one exception.
|
||||
* If just a port is specified, then we prepend a ':' onto the
|
||||
* path (it's what the fastcgi library expects)
|
||||
*/
|
||||
int port = atoi( argv[ 1 ] );
|
||||
if( port ) {
|
||||
char bindport[ 32 ];
|
||||
snprintf( bindport, 32, ":%s", argv[ 1 ] );
|
||||
fcgi_fd = FCGX_OpenSocket( bindport, 128 );
|
||||
} else {
|
||||
fcgi_fd = FCGX_OpenSocket( argv[ 1 ], 128 );
|
||||
}
|
||||
if( fcgi_fd < 0 ) {
|
||||
fprintf( stderr, "Couldn't create FastCGI listen socket\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
} else {
|
||||
fprintf( stderr, "The FastCGI version of PHP cannot be "
|
||||
"run as a CGI application\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate environment size */
|
||||
env_size = 0;
|
||||
while( environ[ env_size ] ) { env_size++; }
|
||||
/* Also include the final NULL pointer */
|
||||
env_size++;
|
||||
|
||||
/* Allocate for our environment */
|
||||
orig_env = malloc( env_size * sizeof( char *));
|
||||
if( !orig_env ) {
|
||||
perror( "Can't malloc environment" );
|
||||
exit( 1 );
|
||||
}
|
||||
memcpy( orig_env, environ, env_size * sizeof( char *));
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#if defined(SIGPIPE) && defined(SIG_IGN)
|
||||
signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so
|
||||
that sockets created via fsockopen()
|
||||
don't kill PHP if the remote site
|
||||
closes it. in apache|apxs mode apache
|
||||
does that for us! thies@thieso.net
|
||||
20000419 */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_startup(1, 1, 0, NULL);
|
||||
#endif
|
||||
sapi_startup(&fastcgi_sapi_module);
|
||||
#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
|
||||
|
||||
if (php_module_startup(&fastcgi_sapi_module)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
#ifdef ZTS
|
||||
compiler_globals = ts_resource(compiler_globals_id);
|
||||
executor_globals = ts_resource(executor_globals_id);
|
||||
core_globals = ts_resource(core_globals_id);
|
||||
sapi_globals = ts_resource(sapi_globals_id);
|
||||
tsrm_ls = ts_resource(0);
|
||||
#endif
|
||||
|
||||
/* How many times to run PHP scripts before dying */
|
||||
if( getenv( "PHP_FCGI_MAX_REQUESTS" )) {
|
||||
max_requests = atoi( getenv( "PHP_FCGI_MAX_REQUESTS" ));
|
||||
if( !max_requests ) {
|
||||
fprintf( stderr,
|
||||
"PHP_FCGI_MAX_REQUESTS is not valid\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PHP_WIN32
|
||||
/* Pre-fork, if required */
|
||||
if( getenv( "PHP_FCGI_CHILDREN" )) {
|
||||
children = atoi( getenv( "PHP_FCGI_CHILDREN" ));
|
||||
if( !children ) {
|
||||
fprintf( stderr,
|
||||
"PHP_FCGI_CHILDREN is not valid\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialise FastCGI request structure */
|
||||
FCGX_Init();
|
||||
FCGX_InitRequest( &request, fcgi_fd, 0 );
|
||||
|
||||
if( children ) {
|
||||
int running = 0;
|
||||
int i;
|
||||
pid_t pid;
|
||||
|
||||
/* Create a process group for ourself & children */
|
||||
setsid();
|
||||
pgroup = getpgrp();
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Process group %d\n", pgroup );
|
||||
#endif
|
||||
|
||||
/* Set up handler to kill children upon exit */
|
||||
act.sa_flags = 0;
|
||||
act.sa_handler = fastcgi_cleanup;
|
||||
if( sigaction( SIGTERM, &act, &old_term ) ||
|
||||
sigaction( SIGINT, &act, &old_int ) ||
|
||||
sigaction( SIGQUIT, &act, &old_quit )) {
|
||||
perror( "Can't set signals" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
while( parent ) {
|
||||
do {
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Forking, %d running\n",
|
||||
running );
|
||||
#endif
|
||||
pid = fork();
|
||||
switch( pid ) {
|
||||
case 0:
|
||||
/* One of the children.
|
||||
* Make sure we don't go round the
|
||||
* fork loop any more
|
||||
*/
|
||||
parent = 0;
|
||||
|
||||
/* don't catch our signals */
|
||||
sigaction( SIGTERM, &old_term, 0 );
|
||||
sigaction( SIGQUIT, &old_quit, 0 );
|
||||
sigaction( SIGINT, &old_int, 0 );
|
||||
break;
|
||||
case -1:
|
||||
perror( "php (pre-forking)" );
|
||||
exit( 1 );
|
||||
break;
|
||||
default:
|
||||
/* Fine */
|
||||
running++;
|
||||
break;
|
||||
}
|
||||
} while( parent && ( running < children ));
|
||||
|
||||
if( parent ) {
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Wait for kids, pid %d\n",
|
||||
getpid() );
|
||||
#endif
|
||||
wait( &status );
|
||||
running--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
/* Main FastCGI loop */
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Going into accept loop\n" );
|
||||
#endif
|
||||
|
||||
while( FCGX_Accept_r( &request ) >= 0 ) {
|
||||
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Got accept\n" );
|
||||
#endif
|
||||
|
||||
in = request.in;
|
||||
out = request.out;
|
||||
err = request.err;
|
||||
cgi_env = request.envp;
|
||||
cgi_env_size = 0;
|
||||
while( cgi_env[ cgi_env_size ] ) { cgi_env_size++; }
|
||||
merge_env = malloc( (env_size+cgi_env_size)*sizeof(char*) );
|
||||
if( !merge_env ) {
|
||||
perror( "Can't malloc environment" );
|
||||
exit( 1 );
|
||||
}
|
||||
memcpy( merge_env, orig_env, (env_size-1)*sizeof(char *) );
|
||||
memcpy( merge_env + env_size - 1,
|
||||
cgi_env, (cgi_env_size+1)*sizeof(char *) );
|
||||
environ = merge_env;
|
||||
|
||||
if (init_request_info(TSRMLS_C)!=0) {
|
||||
/* we received some invalid environment */
|
||||
//char *b = "Can't init the request\n";
|
||||
//sapi_fastcgi_ub_write(b, strlen(b) TSRMLS_C);
|
||||
//FCGX_Finish();
|
||||
//break;
|
||||
}
|
||||
SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */
|
||||
SG(request_info).argv0 = argv0;
|
||||
zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
|
||||
|
||||
fastcgi_module_main(TSRMLS_C);
|
||||
if( path_info ) {
|
||||
free( path_info );
|
||||
path_info = NULL;
|
||||
}
|
||||
|
||||
/* TODO: We should free our environment here, but
|
||||
* some platforms are unhappy if they've altered our
|
||||
* existing environment and we then free() the new
|
||||
* environ pointer
|
||||
*/
|
||||
|
||||
requests++;
|
||||
if( max_requests && ( requests == max_requests )) {
|
||||
FCGX_Finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_shutdown();
|
||||
#endif
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf( stderr, "Exiting...\n" );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="fastcgi" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=fastcgi - Win32 Debug_TS
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "fastcgi.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "fastcgi.mak" CFG="fastcgi - Win32 Debug_TS"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "fastcgi - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "fastcgi - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "fastcgi - Win32 Debug_TS" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "fastcgi - Win32 Release_TS" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "fastcgi - Win32 Release_TS_inline" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "fastcgi - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "..\..\Release"
|
||||
# PROP Intermediate_Dir "..\..\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /Fr /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 php4nts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release/phpfcgi.exe" /libpath:"..\..\Release" /libpath:"fcgi\lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "fastcgi - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "DEBUG" /D "_DEBUG" /D "_CONSOLE" /D "MSVC5" /D "PHP_WIN32" /D ZEND_DEBUG=1 /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 libfcgi.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4nts_debug.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"..\Debug\phpfcgi.exe" /pdbtype:sept /libpath:"..\..\Debug" /libpath:"fcgi\lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "fastcgi - Win32 Debug_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "fastcgi___Win32_Debug_TS"
|
||||
# PROP BASE Intermediate_Dir "fastcgi___Win32_Debug_TS"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug_TS"
|
||||
# PROP Intermediate_Dir "Debug_TS"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "DEBUG" /D "_DEBUG" /D "_CONSOLE" /D "MSVC5" /D "PHP_WIN32" /D ZEND_DEBUG=1 /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /GZ /c
|
||||
# SUBTRACT BASE CPP /YX
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "DEBUG" /D "_DEBUG" /D "_CONSOLE" /D "MSVC5" /D "PHP_WIN32" /D "ZTS" /D ZEND_DEBUG=1 /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 libfcgi.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4nts_debug.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"c:\php-fcgi\php-fcgi.exe" /pdbtype:sept /libpath:"..\..\Debug" /libpath:"fcgi\lib"
|
||||
# ADD LINK32 libfcgi.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /nodefaultlib:"libcd" /nodefaultlib:"libcmt" /out:"..\..\Debug_TS\phpfcgi.exe" /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"fcgi\lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "fastcgi - Win32 Release_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "fastcgi___Win32_Release_TS"
|
||||
# PROP BASE Intermediate_Dir "fastcgi___Win32_Release_TS"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_TS"
|
||||
# PROP Intermediate_Dir "Release_TS"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /Fr /FD /c
|
||||
# SUBTRACT BASE CPP /YX
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZTS" /Fr /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 php4nts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release/php-fcgi.exe" /libpath:"..\..\Release" /libpath:"fcgi\lib"
|
||||
# ADD LINK32 php4ts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release_TS/phpfcgi.exe" /libpath:"..\..\Release_TS" /libpath:"fcgi\lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "fastcgi - Win32 Release_TS_inline"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "fastcgi___Win32_Release_TS_inline"
|
||||
# PROP BASE Intermediate_Dir "fastcgi___Win32_Release_TS_inline"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release_TS_inline"
|
||||
# PROP Intermediate_Dir "Release_TS_inline"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZTS" /Fr /FD /c
|
||||
# SUBTRACT BASE CPP /YX
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\regex\\" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "fcgi\include" /D "NDEBUG" /D "_CONSOLE" /D "ZEND_WIN32_FORCE_INLINE" /D ZEND_DEBUG=0 /D "MSVC5" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZTS" /Fr /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 php4ts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release_TS/phpfcgi.exe" /libpath:"..\..\Release_TS" /libpath:"fcgi\lib"
|
||||
# ADD LINK32 php4ts.lib libfcgi.lib winmm.lib wsock32.lib netapi32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /subsystem:console /machine:I386 /nodefaultlib:"libc.lib" /out:"..\..\Release_TS_inline/phpfcgi.exe" /libpath:"..\..\Release_TS_inline" /libpath:"fcgi\lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "fastcgi - Win32 Release"
|
||||
# Name "fastcgi - Win32 Debug"
|
||||
# Name "fastcgi - Win32 Debug_TS"
|
||||
# Name "fastcgi - Win32 Release_TS"
|
||||
# Name "fastcgi - Win32 Release_TS_inline"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\fastcgi.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\php_fastcgi.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef PHP_FASTCGI_H
|
||||
#define PHP_FASTCGI_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
void fastcgi_php_shutdown(void);
|
||||
void fastcgi_php_init(void);
|
||||
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
Windows support is currently experimental.
|
||||
|
||||
Tested under IIS with cgi-fcgi.exe and Apache with mod_fastcgi.
|
||||
|
||||
Compilation:
|
||||
Currently only supports Non-Thread safe compilation, however,
|
||||
that is realy all that is needed :)
|
||||
|
||||
Get the devkit from www.fastcgi.com, build it.
|
||||
Create the directories
|
||||
php4/sapi/fastcgi/fcgi
|
||||
php4/sapi/fastcgi/fcgi/include
|
||||
php4/sapi/fastcgi/fcgi/lib
|
||||
Place headers and libs in the include and lib directories.
|
||||
Load the php.dsw, and compile.
|
||||
|
||||
IIS configuration:
|
||||
|
||||
Under the application configuration in the IIS configuration program, use:
|
||||
.php C:\php-fcgi\cgi-fcgi.exe -connect php c:\php-fcgi\php-fcgi.exe
|
||||
|
||||
Apache Configuration:
|
||||
|
||||
LoadModule fastcgi_module modules/mod_fastcgi.dll
|
||||
<IfModule mod_fastcgi.c>
|
||||
AddHandler fastcgi-script fphp php
|
||||
</IfModule>
|
||||
|
||||
The scripts require the bang line as the first line
|
||||
of the script to work with mod_fastcgi,
|
||||
#!c:/php-fcgi/php-fcgi.exe
|
||||
|
||||
TODO:
|
||||
make 'thread-safe' compilation, though it isn't necessary.
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
fhttpd
|
||||
Alex Belits
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Alex Belits <abelits@phobos.illtel.denver.co.us> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
#include "php.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if FHTTPD
|
||||
#include <servproc.h>
|
||||
#include <signal.h>
|
||||
|
||||
struct http_server *server = NULL;
|
||||
struct request *req = NULL;
|
||||
struct httpresponse *response = NULL;
|
||||
int headermade = 0;
|
||||
int global_alarmflag = 0;
|
||||
int idle_timeout = IDLE_TIMEOUT;
|
||||
int exit_status = 0;
|
||||
char **currentheader = NULL;
|
||||
char *headerfirstline = NULL;
|
||||
int headerlines = 0;
|
||||
static int headerlinesallocated = 0;
|
||||
|
||||
void alarmhandler(SIGACTARGS)
|
||||
{
|
||||
global_alarmflag = 1;
|
||||
}
|
||||
|
||||
void setalarm(int t)
|
||||
{
|
||||
struct sigaction tmpsigaction;
|
||||
global_alarmflag = 0;
|
||||
if (t){
|
||||
bzero((char *) &tmpsigaction, sizeof(struct sigaction));
|
||||
tmpsigaction.sa_handler = alarmhandler;
|
||||
sigaddset(&tmpsigaction.sa_mask, SIGALRM);
|
||||
tmpsigaction.sa_flags = 0;
|
||||
sigaction(SIGALRM, &tmpsigaction, NULL);
|
||||
alarm(t);
|
||||
}
|
||||
}
|
||||
|
||||
int checkinput(int h)
|
||||
{
|
||||
fd_set readfd;
|
||||
FD_ZERO(&readfd);
|
||||
FD_SET(h, &readfd);
|
||||
return select(h + 1, &readfd, NULL, NULL, NULL) > 0;
|
||||
}
|
||||
|
||||
|
||||
PHPAPI void php_fhttpd_free_header(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (headerfirstline) {
|
||||
free(headerfirstline);
|
||||
headerfirstline = NULL;
|
||||
}
|
||||
if (currentheader) {
|
||||
for (i = 0; i < headerlines; i++) {
|
||||
free(currentheader[i]);
|
||||
}
|
||||
free(currentheader);
|
||||
currentheader = NULL;
|
||||
}
|
||||
headerlines = 0;
|
||||
headerlinesallocated = 0;
|
||||
headermade = 0;
|
||||
}
|
||||
|
||||
|
||||
PHPAPI void php_fhttpd_puts_header(char *s)
|
||||
{
|
||||
char *p0, *p1, *p2, *p3, **p;
|
||||
int l;
|
||||
|
||||
if (!s || !*s || *s == '\r' || *s == '\n')
|
||||
return;
|
||||
l = strlen(s);
|
||||
p2 = strchr(s, '\r');
|
||||
p3 = strchr(s, '\n');
|
||||
p0 = strchr(s, ':');
|
||||
p1 = strchr(s, ' ');
|
||||
if (p0 && (!p1 || p1 > p0)) {
|
||||
if (!headerlinesallocated) {
|
||||
currentheader = (char **) malloc(10 * sizeof(char *));
|
||||
if (currentheader)
|
||||
headerlinesallocated = 10;
|
||||
} else {
|
||||
if (headerlinesallocated <= headerlines) {
|
||||
p = (char **) realloc(currentheader, (headerlinesallocated + 10) * sizeof(char *));
|
||||
if (p) {
|
||||
currentheader = p;
|
||||
headerlinesallocated += 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (headerlinesallocated > headerlines) {
|
||||
currentheader[headerlines] = malloc(l + 3);
|
||||
if (currentheader[headerlines]) {
|
||||
strcpy(currentheader[headerlines], s);
|
||||
if (!p3) {
|
||||
if (p2) {
|
||||
(currentheader[headerlines] + (p2 - s))[1] = '\n';
|
||||
(currentheader[headerlines] + (p2 - s))[2] = 0;
|
||||
} else {
|
||||
currentheader[headerlines][l] = '\r';
|
||||
currentheader[headerlines][l + 1] = '\n';
|
||||
currentheader[headerlines][l + 2] = 0;
|
||||
}
|
||||
}
|
||||
headerlines++;
|
||||
headermade = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (headerfirstline)
|
||||
free(headerfirstline);
|
||||
headerfirstline = malloc(l + 3);
|
||||
if (headerfirstline) {
|
||||
strcpy(headerfirstline, s);
|
||||
if (!p3) {
|
||||
if (p2) {
|
||||
(headerfirstline + (p2 - s))[1] = '\n';
|
||||
(headerfirstline + (p2 - s))[2] = 0;
|
||||
} else {
|
||||
headerfirstline[l] = '\r';
|
||||
headerfirstline[l + 1] = '\n';
|
||||
headerfirstline[l + 2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
headermade = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void fhttpd_flush(void)
|
||||
{
|
||||
}
|
||||
|
||||
PHPAPI void php_fhttpd_puts(char *s)
|
||||
{
|
||||
putlinetoresponse(response, s);
|
||||
}
|
||||
|
||||
PHPAPI void php_fhttpd_putc(char c)
|
||||
{
|
||||
writetoresponse(response, &c, 1);
|
||||
}
|
||||
|
||||
PHPAPI int php_fhttpd_write(char *a, int n)
|
||||
{
|
||||
return writetoresponse(response, a, n);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id$
|
||||
|
||||
dir=$1; shift
|
||||
for stubfile in $dir/*/config0.m4 $dir/*/config.m4; do
|
||||
echo "sinclude($stubfile)"
|
||||
done
|
||||
@@ -1,30 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# do some automatic conversion of prototypes
|
||||
#
|
||||
|
||||
if test "$1" = "" ; then
|
||||
echo "usage: $0 list-of-files"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmpfile=`mktemp -q /tmp/asd.XXXXXX`
|
||||
|
||||
if test "$?" != "0" ; then
|
||||
echo "$0: cannot create temporary file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for file in ${1+"$@"} ; do
|
||||
echo "working on $file"
|
||||
cat $file | \
|
||||
sed -e \
|
||||
's/void php3_\(.*\)(INTERNAL_FUNCTION_PARAMETERS)/PHP_FUNCTION(\1)/' \
|
||||
-e 's/^extern void /void /' \
|
||||
-e 's/^extern PHP_FUNCTION/PHP_FUNCTION/' > $tmpfile
|
||||
cp $tmpfile $file
|
||||
done
|
||||
|
||||
rm -f $tmpfile
|
||||
|
||||
exit 0
|
||||
@@ -1,61 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# +----------------------------------------------------------------------+
|
||||
# | PHP Version 4 |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Copyright (c) 1997-2002 The PHP Group |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | This source file is subject to version 2.02 of the PHP license, |
|
||||
# | that is bundled with this package in the file LICENSE, and is |
|
||||
# | available at through the world-wide-web at |
|
||||
# | http://www.php.net/license/2_02.txt. |
|
||||
# | If you did not receive a copy of the PHP license and are unable to |
|
||||
# | obtain it through the world-wide-web, please send a note to |
|
||||
# | license@php.net so we can mail you a copy immediately. |
|
||||
# +----------------------------------------------------------------------+
|
||||
# | Author: Sascha Schumann <sascha@schumann.cx> |
|
||||
# +----------------------------------------------------------------------+
|
||||
#
|
||||
# $Id$
|
||||
|
||||
for i in $@; do
|
||||
echo -n "Processing $i... "
|
||||
sed \
|
||||
-e 's/(\*\([^()]\+\))->type/Z_TYPE_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->type/Z_TYPE_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.type/Z_TYPE(\1)/g' \
|
||||
-e 's/(\*\([^()]\+\))->value\.dval/Z_DVAL_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->value\.dval/Z_DVAL_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.dval/Z_DVAL(\1)/g' \
|
||||
-e 's/(\*\([^()]\+\))->value\.lval/Z_LVAL_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->value\.lval/Z_LVAL_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.lval/Z_LVAL(\1)/g' \
|
||||
-e 's/(\*\([^()]\+\))->value\.ht/Z_ARRVAL_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->value\.ht/Z_ARRVAL_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.ht/Z_ARRVAL(\1)/g' \
|
||||
-e 's/(\*\([^()]\+\))->value\.str\.val/Z_STRVAL_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->value\.str\.val/Z_STRVAL_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.str\.val/Z_STRVAL(\1)/g' \
|
||||
-e 's/(\*\([^()]\+\))->value\.str\.len/Z_STRLEN_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->value\.str\.len/Z_STRLEN_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.str\.len/Z_STRLEN(\1)/g' \
|
||||
-e 's/(\*\([^()]\+\))->value\.obj\.properties/Z_OBJPROP_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->value\.obj\.properties/Z_OBJPROP_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.obj\.properties/Z_OBJPROP(\1)/g' \
|
||||
-e 's/(\*\([^()]\+\))->value\.obj\.ce/Z_OBJCE_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->value\.obj\.ce/Z_OBJCE_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.obj\.ce/Z_OBJCE(\1)/g' \
|
||||
-e 's/(\*\([^()]\+\))->value\.obj/Z_OBJ_PP(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)->value\.obj/Z_OBJ_P(\1)/g' \
|
||||
-e 's/\([a-z_][]a-z_0-9\[]*\)\.value\.obj/Z_OBJ(\1)/g' \
|
||||
-e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)->Z_\([A-Z_]\+\)(/Z_\2(\1->/g' \
|
||||
-e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)->Z_\([A-Z_]\+\)(/Z_\2(\1->/g' \
|
||||
-e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)->Z_\([A-Z_]\+\)(/Z_\2(\1->/g' \
|
||||
-e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)\.Z_\([A-Z_]\+\)(/Z_\2(\1./g' \
|
||||
-e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)\.Z_\([A-Z_]\+\)(/Z_\2(\1./g' \
|
||||
-e 's/\([a-zA-Z_][a-zA-Z_0-9]*\)\.Z_\([A-Z_]\+\)(/Z_\2(\1./g' \
|
||||
< $i > tmp && cp tmp $i
|
||||
echo "DONE"
|
||||
done
|
||||
|
||||
rm -f tmp
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
awkprog='
|
||||
BEGIN { FS = "\n"; RS = "" }
|
||||
{ print "CREDIT_LINE(\""$1"\", \""$2"\");" }'
|
||||
|
||||
for what in ext sapi
|
||||
do
|
||||
file=ext/standard/credits_$what.h
|
||||
cat >$file <<END
|
||||
/*
|
||||
DO NOT EDIT THIS FILE!
|
||||
|
||||
it has been automaticaly created by php4/scripts/credits from
|
||||
the information found in the various php4/ext/.../CREDITS and
|
||||
php4/sapi/.../CREDITS files
|
||||
|
||||
if you want to change an entry you have to edit the appropriate
|
||||
CREDITS file instead
|
||||
|
||||
*/
|
||||
|
||||
END
|
||||
# Do not process skeleton #
|
||||
files=`find "$what" -name CREDITS | grep -v "$what"/skeleton/CREDITS`
|
||||
awk "$awkprog" $files | sort -f >> $file
|
||||
done
|
||||
@@ -1,60 +0,0 @@
|
||||
PHP Regression Tests
|
||||
====================
|
||||
|
||||
To run the tests, go to the top-level directory and
|
||||
run "./php -q run-tests.php".
|
||||
|
||||
Without parameters, "run-tests.php" will recursively scan through the
|
||||
file tree looking for directories called "tests", and run all the
|
||||
tests (.phpt files) within (recursively).
|
||||
|
||||
To run tests in a single directory, pass the directory as a parameter:
|
||||
"./php -q run-tests.php tests/lang".
|
||||
|
||||
To run one or more single tests, pass them as parameters:
|
||||
"./php -q run-tests.php tests/lang/015.phpt".
|
||||
|
||||
The format of the .phpt files is quite simple. There are 6 possible
|
||||
sections. Test, Skipif, Post, Get, File and Expect. The Test section
|
||||
contains the description of the test. The Skipif section contains
|
||||
code that should print "skip" if this test should be skipped for some
|
||||
reason (such as an extension that is not compiled in). The Post
|
||||
section contains any post data that the script might need. The Get
|
||||
section contains any Get data. Note that both the Post and the Get
|
||||
sections need to have this data in url-encoded format. The File
|
||||
section contains the actual script and the Expect section is the
|
||||
expected output, sans headers. Blank lines are ignored in the
|
||||
expected output.
|
||||
|
||||
A simple example which takes one argument through the POST method
|
||||
and one through the GET and displays these would be:
|
||||
|
||||
--TEST--
|
||||
Simple GET and POST test
|
||||
--SKIPIF--
|
||||
--POST--
|
||||
a=Hello
|
||||
--GET--
|
||||
b=There
|
||||
--FILE--
|
||||
<?php echo "$a $b">
|
||||
--EXPECT--
|
||||
Hello There
|
||||
|
||||
Another simple example that only runs if the PCRE extension is loaded:
|
||||
|
||||
--TEST--
|
||||
Simple Perl regexp test
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pcre")) print "skip"; ?>
|
||||
--POST--
|
||||
--GET--
|
||||
--FILE--
|
||||
<?php
|
||||
$str="Hello 42 World";
|
||||
if (pcre_match('/^([a-z]+)\s+(\d+)\s+([a-z]+)/i', $str, $matches)) {
|
||||
printf("%s %s: %d\n", $matches[1], $matches[3], $matches[2]);
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Hello World: 42
|
||||
@@ -1,30 +0,0 @@
|
||||
--TEST--
|
||||
dirname test
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function check_dirname($path)
|
||||
{
|
||||
print "dirname($path) == " . dirname($path) . "\n";
|
||||
}
|
||||
|
||||
check_dirname("/foo/");
|
||||
check_dirname("/foo");
|
||||
check_dirname("/foo/bar");
|
||||
check_dirname("d:\\foo\\bar.inc");
|
||||
check_dirname("/");
|
||||
check_dirname(".../foo");
|
||||
check_dirname("./foo");
|
||||
check_dirname("foobar///");
|
||||
check_dirname("c:\foo");
|
||||
?>
|
||||
--EXPECT--
|
||||
dirname(/foo/) == /
|
||||
dirname(/foo) == /
|
||||
dirname(/foo/bar) == /foo
|
||||
dirname(d:\foo\bar.inc) == .
|
||||
dirname(/) == /
|
||||
dirname(.../foo) == ...
|
||||
dirname(./foo) == .
|
||||
dirname(foobar///) == .
|
||||
dirname(c:\foo) == .
|
||||
Reference in new issue
Block a user