Skip to content
Browse files

Fixed line endings to \n

  • Loading branch information...
1 parent a1220c6 commit 8d0b570f0e63f2ee6e3e5dddba87de9653400477 @pp3345 committed Feb 17, 2013
Sorry, we could not display the entire diff because it was too big.
View
4 .gitattributes
@@ -1,2 +1,2 @@
-# Disable LF normalization for all files
-* -text
+# Force LF
+* text eol=lf
View
148 README.md
@@ -1,75 +1,75 @@
-# [Pancake HTTP Server](http://pancakehttp.net)
-
-## What is Pancake?
-
-Pancake is a lightweight and fast web server created by [Yussuf Khalil](https://github.com/pp3345), mainly written in C, PHP and Moody.
-The main goal of Pancake is achieving the best possible PHP script execution performance using its own PHP SAPI, however,
-you may use nearly any server-side scripting language using the FastCGI and AJP13 interfaces. Thanks to the non-blocking server architecture
-Pancake can also handle very high concurrency loads. Try it out!
-
-## System requirements
-
-* Linux
-* PHP 5.4.0 or newer
-* i686 or x86_64 processor or Raspberry Pi (no *official* support for other ARM architectures)
-
-## Installation
-
-Installing Pancake is quite easy. Simply download the current version and extract it anywhere on the target computer.
-Then add the executable flag to the Pancake/sys/pancake.sh file and run it. On most systems the following commands should do the job:
-
- wget http://github.com/pp3345/Pancake/tarball/<version>
- tar -zxvf <version>
- mv pp3345-Pancake-* Pancake
- cd Pancake/sys
- chmod +x pancake.sh
- sudo ./pancake.sh
-
-As you can see, `sudo` is used to run `pancake.sh` as root user. In case you're already root or your system uses another command (for example `su`)
-please choose the appropriate command. Make sure you are allowed to write in the directory you want to install Pancake in.
-
-## Upgrading from older versions
-
-You can simply overwrite your old Pancake. No configurations or vHosts will go lost. However, if there is an `UPGRADING` file in the root directory
-of the new Pancake, please make sure to read it first. It usually contains information about possible incompatibilities when upgrading.
-
-## Documentation
-
-Documentation and information about the configuration of Pancake can be found at the [Pancake Wiki](https://github.com/pp3345/Pancake/wiki).
-
-## Bundled init script
-
-Pancake now has an official init script for Debian GNU/Linux (and Debian-derived distributions like Ubuntu or Raspbian) bundled.
-The script is located in the main directory of Pancake. Run the following commands to use it:
-
- cd <PancakeDirectory>
- sudo cp init /etc/init.d/pancake
- sudo update-rc.d pancake enable
-
-In case your Pancake is **not** installed in /usr/local/Pancake, please change the `DAEMON` line in the script to match your Pancake installation path.
-
-You can then start your Pancake using
-
- sudo /etc/init.d/pancake start
-
-and stop it again using
-
- sudo /etc/init.d/pancake stop
-
-Pancake will also be automatically run when your computer starts up.
-
-The script is bundled with kind permission of [Jan Erik Petersen](https://github.com/marco01809).
-
-## Contact
-
-If you need help or have a question about Pancake, please feel free to write a mail to [support@pancakehttp.net](mailto:support@pancakehttp.net).
-I love to hear from you. :-)
-
-## Donations
-
-If you love your tasty Pancake and my work, how about donating a few bucks via PayPal? :-) [![PayPal Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=89CFQ7SFX3MWY)
-
-## License
-
-Pancake is currently licensed under its own [license](http://pancakehttp.net/license/).
+# [Pancake HTTP Server](http://pancakehttp.net)
+
+## What is Pancake?
+
+Pancake is a lightweight and fast web server created by [Yussuf Khalil](https://github.com/pp3345), mainly written in C, PHP and Moody.
+The main goal of Pancake is achieving the best possible PHP script execution performance using its own PHP SAPI, however,
+you may use nearly any server-side scripting language using the FastCGI and AJP13 interfaces. Thanks to the non-blocking server architecture
+Pancake can also handle very high concurrency loads. Try it out!
+
+## System requirements
+
+* Linux
+* PHP 5.4.0 or newer
+* i686 or x86_64 processor or Raspberry Pi (no *official* support for other ARM architectures)
+
+## Installation
+
+Installing Pancake is quite easy. Simply download the current version and extract it anywhere on the target computer.
+Then add the executable flag to the Pancake/sys/pancake.sh file and run it. On most systems the following commands should do the job:
+
+ wget http://github.com/pp3345/Pancake/tarball/<version>
+ tar -zxvf <version>
+ mv pp3345-Pancake-* Pancake
+ cd Pancake/sys
+ chmod +x pancake.sh
+ sudo ./pancake.sh
+
+As you can see, `sudo` is used to run `pancake.sh` as root user. In case you're already root or your system uses another command (for example `su`)
+please choose the appropriate command. Make sure you are allowed to write in the directory you want to install Pancake in.
+
+## Upgrading from older versions
+
+You can simply overwrite your old Pancake. No configurations or vHosts will go lost. However, if there is an `UPGRADING` file in the root directory
+of the new Pancake, please make sure to read it first. It usually contains information about possible incompatibilities when upgrading.
+
+## Documentation
+
+Documentation and information about the configuration of Pancake can be found at the [Pancake Wiki](https://github.com/pp3345/Pancake/wiki).
+
+## Bundled init script
+
+Pancake now has an official init script for Debian GNU/Linux (and Debian-derived distributions like Ubuntu or Raspbian) bundled.
+The script is located in the main directory of Pancake. Run the following commands to use it:
+
+ cd <PancakeDirectory>
+ sudo cp init /etc/init.d/pancake
+ sudo update-rc.d pancake enable
+
+In case your Pancake is **not** installed in /usr/local/Pancake, please change the `DAEMON` line in the script to match your Pancake installation path.
+
+You can then start your Pancake using
+
+ sudo /etc/init.d/pancake start
+
+and stop it again using
+
+ sudo /etc/init.d/pancake stop
+
+Pancake will also be automatically run when your computer starts up.
+
+The script is bundled with kind permission of [Jan Erik Petersen](https://github.com/marco01809).
+
+## Contact
+
+If you need help or have a question about Pancake, please feel free to write a mail to [support@pancakehttp.net](mailto:support@pancakehttp.net).
+I love to hear from you. :-)
+
+## Donations
+
+If you love your tasty Pancake and my work, how about donating a few bucks via PayPal? :-) [![PayPal Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=89CFQ7SFX3MWY)
+
+## License
+
+Pancake is currently licensed under its own [license](http://pancakehttp.net/license/).
However, the license will probably change soon. In case you have any questions about the license, please contact [support@pancakehttp.net](mailto:support@pancakehttp.net).
View
98 conf/config.example.yml
@@ -1,50 +1,50 @@
-main:
- tmpPath: ../tmp/ # Path for temporary files
- logging:
- system: ../log/system.log # Path to System-Log
- request: ../log/requests.log # Path to Request-Log
- error: ../log/error.log # Path to Error-Log
- dateFormat: 'd.m.y H:i:s' # Format for timestamps - See php.net/date for more information
- debugMode: false # Enable debugging (debugging can also be enabled for a single run by setting the option --debug)
- user: www-data # *NIX-User under which Pancake should run
- group: www-data # *NIX-Group under which Pancake should run
- listenPorts: # List of ports to listen on (Recommended for HTTP: 80)
- - 80
- IPv4: # IPv4 network interfaces to listen on (use 0 to listen on all available interfaces)
- - 0
- IPv6: # IPv6 network interfaces to listen on (use ::0 to listen on all available interfaces)
- - ::0
- requestWorkers: 4 # Amount of RequestWorkers to run
- exposePancake: true # If true, Pancake will send a "Server"-Header with Information about Pancake
- sizePrefix: bin # "si" or "bin" - SI: 1000 Byte = 1 Kilobyte - Binary: 1024 Byte = 1 Kibibyte
- allowHEAD: true # Whether to allow the "HEAD"-requestmethod
- allowTRACE: true # Whether to allow the "TRACE"-requestmethod
- allowOPTIONS: true # Whether to allow the "OPTIONS"-requestmethod
- requestWorkerLimit: 50000 # Limit of requests a RequestWorker may process until it has to be restarted (0 for no limit)
- maxConcurrent: 0 # Limit of concurrent connections a RequestWorker may hold open (0 for no limit)
- workerBootTime: 5 # The upper timelimit for a worker to boot (raise this when you're for example caching files that take long to load)
- writeBufferMin: 10240 # Minimum write buffer size that should be held in RAM
- writeBufferSoftMaxConcurrent: 50 # Soft concurrent write buffer limit - When this limit is reached, Pancake won't allocate any buffers that are bigger than the minimum size anymore
- writeBufferHardMaxConcurrent: 2000 # Hard concurrent write buffer limit - When this limit is reached, Pancake will try not to allocate any buffers anymore
- waitPHPWorkerBoot: true # Wait for PHP-Workers to boot (should be disabled in shared environments)
- waitSlotTime: 5000 # When there is no PHPWorker available to serve a PHP-request, Pancake will check after waitslottime µsec if a slot became available
- waitSlotWaitLimit: 5 # See above; this is the upper limit of wait-cycles until Pancake gives up on searching for a slot (for example: waitslottime = 5000; waitslotwaitlimit = 5 => Client will receive 500 Internal Server Error after 25 ms if no PHPWorker became available in those 25 ms)
- socketBacklog: 100 # Connection backlog for incoming requests
-include: # Additional configuration-files to include
- - ../conf/vhosts/
- - ../conf/mime.yml
-moody:
- deletewhitespaces: false
- deletecomments: true
-FastCGI: # FastCGI upstream server configurations
-# php: # This example configuration could be used to use the native php-fpm SAPI instead of the Pancake SAPI for executing PHP
-# type: unix
-# address: /var/run/php5-fpm.socket
-# mimeTypes:
-# - text/x-php
-AJP13: # AJP13 upstream server configurations
-# jenkins: # This example configuration could be used to run Jenkins behind Pancake
-# type: ipv4
-# address: 127.0.0.1
-# port: 1030
+main:
+ tmpPath: ../tmp/ # Path for temporary files
+ logging:
+ system: ../log/system.log # Path to System-Log
+ request: ../log/requests.log # Path to Request-Log
+ error: ../log/error.log # Path to Error-Log
+ dateFormat: 'd.m.y H:i:s' # Format for timestamps - See php.net/date for more information
+ debugMode: false # Enable debugging (debugging can also be enabled for a single run by setting the option --debug)
+ user: www-data # *NIX-User under which Pancake should run
+ group: www-data # *NIX-Group under which Pancake should run
+ listenPorts: # List of ports to listen on (Recommended for HTTP: 80)
+ - 80
+ IPv4: # IPv4 network interfaces to listen on (use 0 to listen on all available interfaces)
+ - 0
+ IPv6: # IPv6 network interfaces to listen on (use ::0 to listen on all available interfaces)
+ - ::0
+ requestWorkers: 4 # Amount of RequestWorkers to run
+ exposePancake: true # If true, Pancake will send a "Server"-Header with Information about Pancake
+ sizePrefix: bin # "si" or "bin" - SI: 1000 Byte = 1 Kilobyte - Binary: 1024 Byte = 1 Kibibyte
+ allowHEAD: true # Whether to allow the "HEAD"-requestmethod
+ allowTRACE: true # Whether to allow the "TRACE"-requestmethod
+ allowOPTIONS: true # Whether to allow the "OPTIONS"-requestmethod
+ requestWorkerLimit: 50000 # Limit of requests a RequestWorker may process until it has to be restarted (0 for no limit)
+ maxConcurrent: 0 # Limit of concurrent connections a RequestWorker may hold open (0 for no limit)
+ workerBootTime: 5 # The upper timelimit for a worker to boot (raise this when you're for example caching files that take long to load)
+ writeBufferMin: 10240 # Minimum write buffer size that should be held in RAM
+ writeBufferSoftMaxConcurrent: 50 # Soft concurrent write buffer limit - When this limit is reached, Pancake won't allocate any buffers that are bigger than the minimum size anymore
+ writeBufferHardMaxConcurrent: 2000 # Hard concurrent write buffer limit - When this limit is reached, Pancake will try not to allocate any buffers anymore
+ waitPHPWorkerBoot: true # Wait for PHP-Workers to boot (should be disabled in shared environments)
+ waitSlotTime: 5000 # When there is no PHPWorker available to serve a PHP-request, Pancake will check after waitslottime µsec if a slot became available
+ waitSlotWaitLimit: 5 # See above; this is the upper limit of wait-cycles until Pancake gives up on searching for a slot (for example: waitslottime = 5000; waitslotwaitlimit = 5 => Client will receive 500 Internal Server Error after 25 ms if no PHPWorker became available in those 25 ms)
+ socketBacklog: 100 # Connection backlog for incoming requests
+include: # Additional configuration-files to include
+ - ../conf/vhosts/
+ - ../conf/mime.yml
+moody:
+ deletewhitespaces: false
+ deletecomments: true
+FastCGI: # FastCGI upstream server configurations
+# php: # This example configuration could be used to use the native php-fpm SAPI instead of the Pancake SAPI for executing PHP
+# type: unix
+# address: /var/run/php5-fpm.socket
+# mimeTypes:
+# - text/x-php
+AJP13: # AJP13 upstream server configurations
+# jenkins: # This example configuration could be used to run Jenkins behind Pancake
+# type: ipv4
+# address: 127.0.0.1
+# port: 1030
# maxconcurrent: 100
View
320 init
@@ -1,161 +1,161 @@
-#! /bin/sh
-
-### BEGIN INIT INFO
-# Provides: pancake
-# Required-Start: $all
-# Required-Stop: $all
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Pancake
-# Description: Pancake HTTP Server
-### END INIT INFO
-
-# Author: Jan Erik Petersen <Marco01_809@web.de>
-# Requires Pancake 1.3 or newer
-
-PATH=/sbin:/usr/local/sbin:/usr/sbin:/bin:/usr/local/bin:/usr/bin
-
-DESC="Pancake HTTP Server"
-NAME=pancake
-
-PIDFILE=/var/run/$NAME.pid
-SCRIPTNAME=/etc/init.d/$NAME
-
-DAEMON=/usr/local/Pancake/sys/pancake.sh
-DAEMON_ARGS="--daemon --pidfile=$PIDFILE"
-
-STOP_WAIT_SECS=30
-
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
-
-# Read configuration variable file if it is present
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
-
-# 0 -> Process running ($PIDFILE exists)
-# 1 -> Process not running, $PIDFILE doesn't exist
-# 2 -> Process not running, $PIDFILE exists
-get_status() {
- [ ! -r $PIDFILE ] && return 1
- PID=`cat $PIDFILE`
- kill -0 $PID >/dev/null 2>/dev/null
- [ $? = 0 ] && return 0 || return 2
-}
-
-# 0 -> Process started successfully
-# 1 -> Process was running
-# 2 -> Couldn't start process
-do_start() {
- get_status
- [ $? = 0 ] && return 1
-
- $DAEMON $DAEMON_ARGS >/dev/null
- [ $? = 0 ] && return 0 || return 2
-}
-
-# 0 -> Process stopped successfully
-# 1 -> Process wasn't running
-# 2 -> Couldn't stop process
-do_stop() {
- get_status
- [ $? != 0 ] && return 1
-
- kill -TERM $PID
- [ $? != 0 ] && return 2
-
- local tries=0
- while [ $tries -lt $STOP_WAIT_SECS ]; do
- sleep 1
- get_status
- if [ $? != 0 ]; then
- rm -f $PIDFILE
- return 0
- fi
- tries=$((tries+1))
- done
-
- kill -KILL $PID
- [ $? != 0 ] && return 2
- sleep 2
-
- get_status
- if [ $? != 0 ]; then
- rm -f $PIDFILE
- return 0
- fi
- return 2
-}
-
-# 0 -> SIGHUP sent successfully
-# 1 -> Process wasn't running
-# 2 -> Couldn't send SIGHUP
-do_reload() {
- get_status
- [ $? != 0 ] && return 1
-
- kill -1 $PID >/dev/null 2>/dev/null
- [ $? = 0 ] && return 0 || return 2
-}
-
-case "$1" in
- start)
- echo -n "Starting $DESC: "
- do_start
- status=$?
- [ $status = 0 ] && echo "$NAME."
- [ $status = 1 ] && echo "ERROR: $NAME is already running."
- [ $status = 2 ] && echo "ERROR: Couldn't start $NAME."
- exit $status
- ;;
- stop)
- echo -n "Stopping $DESC: "
- do_stop
- status=$?
- [ $status = 0 ] && echo "$NAME."
- [ $status = 1 ] && echo "ERROR: $NAME is not running."
- [ $status = 2 ] && echo "ERROR: Couldn't stop $NAME."
- exit $status
- ;;
- restart|force-reload)
- echo -n "Restarting $DESC: "
- do_stop
- status=$?
- [ $status = 1 ] && echo -n "WARNING: $NAME was not running: "
- [ $status = 2 ] && echo "ERROR: Couldn't stop $NAME." && exit 2
- do_start
- status=$?
- [ $status = 0 ] && echo "$NAME."
- [ $status = 1 ] && echo "ERROR: $NAME is already running."
- [ $status = 2 ] && echo "ERROR: Couldn't start $NAME."
- exit $status
- ;;
- reload)
- echo -n "Reloading $DESC: "
- do_reload
- status=$?
- [ $status = 0 ] && echo "$NAME."
- [ $status = 1 ] && echo "ERROR: $NAME is not running."
- [ $status = 2 ] && echo "ERROR: Couldn't reload $NAME."
- exit $status
- ;;
- status)
- get_status
- status=$?
- case "$status" in
- 0)
- echo "$DESC is running. PID: $PID"
- ;;
- 1)
- echo "$DESC is not running"
- ;;
- 2)
- echo "$DESC is not running, but $PIDFILE still exists"
- ;;
- esac
- exit $status
- ;;
- *)
- echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}"
- exit 3
- ;;
+#! /bin/sh
+
+### BEGIN INIT INFO
+# Provides: pancake
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Pancake
+# Description: Pancake HTTP Server
+### END INIT INFO
+
+# Author: Jan Erik Petersen <Marco01_809@web.de>
+# Requires Pancake 1.3 or newer
+
+PATH=/sbin:/usr/local/sbin:/usr/sbin:/bin:/usr/local/bin:/usr/bin
+
+DESC="Pancake HTTP Server"
+NAME=pancake
+
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+DAEMON=/usr/local/Pancake/sys/pancake.sh
+DAEMON_ARGS="--daemon --pidfile=$PIDFILE"
+
+STOP_WAIT_SECS=30
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# 0 -> Process running ($PIDFILE exists)
+# 1 -> Process not running, $PIDFILE doesn't exist
+# 2 -> Process not running, $PIDFILE exists
+get_status() {
+ [ ! -r $PIDFILE ] && return 1
+ PID=`cat $PIDFILE`
+ kill -0 $PID >/dev/null 2>/dev/null
+ [ $? = 0 ] && return 0 || return 2
+}
+
+# 0 -> Process started successfully
+# 1 -> Process was running
+# 2 -> Couldn't start process
+do_start() {
+ get_status
+ [ $? = 0 ] && return 1
+
+ $DAEMON $DAEMON_ARGS >/dev/null
+ [ $? = 0 ] && return 0 || return 2
+}
+
+# 0 -> Process stopped successfully
+# 1 -> Process wasn't running
+# 2 -> Couldn't stop process
+do_stop() {
+ get_status
+ [ $? != 0 ] && return 1
+
+ kill -TERM $PID
+ [ $? != 0 ] && return 2
+
+ local tries=0
+ while [ $tries -lt $STOP_WAIT_SECS ]; do
+ sleep 1
+ get_status
+ if [ $? != 0 ]; then
+ rm -f $PIDFILE
+ return 0
+ fi
+ tries=$((tries+1))
+ done
+
+ kill -KILL $PID
+ [ $? != 0 ] && return 2
+ sleep 2
+
+ get_status
+ if [ $? != 0 ]; then
+ rm -f $PIDFILE
+ return 0
+ fi
+ return 2
+}
+
+# 0 -> SIGHUP sent successfully
+# 1 -> Process wasn't running
+# 2 -> Couldn't send SIGHUP
+do_reload() {
+ get_status
+ [ $? != 0 ] && return 1
+
+ kill -1 $PID >/dev/null 2>/dev/null
+ [ $? = 0 ] && return 0 || return 2
+}
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: "
+ do_start
+ status=$?
+ [ $status = 0 ] && echo "$NAME."
+ [ $status = 1 ] && echo "ERROR: $NAME is already running."
+ [ $status = 2 ] && echo "ERROR: Couldn't start $NAME."
+ exit $status
+ ;;
+ stop)
+ echo -n "Stopping $DESC: "
+ do_stop
+ status=$?
+ [ $status = 0 ] && echo "$NAME."
+ [ $status = 1 ] && echo "ERROR: $NAME is not running."
+ [ $status = 2 ] && echo "ERROR: Couldn't stop $NAME."
+ exit $status
+ ;;
+ restart|force-reload)
+ echo -n "Restarting $DESC: "
+ do_stop
+ status=$?
+ [ $status = 1 ] && echo -n "WARNING: $NAME was not running: "
+ [ $status = 2 ] && echo "ERROR: Couldn't stop $NAME." && exit 2
+ do_start
+ status=$?
+ [ $status = 0 ] && echo "$NAME."
+ [ $status = 1 ] && echo "ERROR: $NAME is already running."
+ [ $status = 2 ] && echo "ERROR: Couldn't start $NAME."
+ exit $status
+ ;;
+ reload)
+ echo -n "Reloading $DESC: "
+ do_reload
+ status=$?
+ [ $status = 0 ] && echo "$NAME."
+ [ $status = 1 ] && echo "ERROR: $NAME is not running."
+ [ $status = 2 ] && echo "ERROR: Couldn't reload $NAME."
+ exit $status
+ ;;
+ status)
+ get_status
+ status=$?
+ case "$status" in
+ 0)
+ echo "$DESC is running. PID: $PID"
+ ;;
+ 1)
+ echo "$DESC is not running"
+ ;;
+ 2)
+ echo "$DESC is not running, but $PIDFILE still exists"
+ ;;
+ esac
+ exit $status
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}"
+ exit 3
+ ;;
esac
View
BIN logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
242 logo.svg
@@ -1,121 +1,121 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
-<svg version="1.1" baseProfile="tiny" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
- x="0px" y="0px" width="521px" height="131px" viewBox="0 0 521 131" xml:space="preserve">
-<g>
- <path d="M62.224,67.468c0,5.763-0.623,10.938-1.868,15.527c-1.245,4.591-3.076,8.485-5.493,11.683
- c-2.417,3.198-5.409,5.664-8.972,7.396c-3.565,1.732-7.643,2.601-12.231,2.601c-1.954,0-3.761-0.196-5.42-0.586
- c-1.661-0.392-3.285-1-4.871-1.831c-1.587-0.83-3.162-1.879-4.724-3.149c-1.563-1.269-3.223-2.758-4.98-4.468V127.6
- c0,0.391-0.099,0.732-0.293,1.025c-0.196,0.293-0.513,0.537-0.952,0.732c-0.439,0.194-1.051,0.341-1.831,0.439
- c-0.782,0.098-1.783,0.146-3.003,0.146c-1.172,0-2.149-0.049-2.93-0.146c-0.782-0.099-1.404-0.245-1.868-0.439
- c-0.465-0.195-0.782-0.439-0.952-0.732c-0.172-0.293-0.256-0.635-0.256-1.025V35.534c0-0.439,0.073-0.793,0.22-1.062
- c0.146-0.268,0.439-0.5,0.879-0.696c0.439-0.194,1-0.329,1.685-0.403c0.683-0.072,1.513-0.109,2.49-0.109
- c1.025,0,1.868,0.037,2.527,0.109c0.659,0.074,1.208,0.209,1.648,0.403c0.439,0.196,0.744,0.429,0.916,0.696
- c0.17,0.269,0.256,0.622,0.256,1.062v8.862c2.001-2.051,3.93-3.832,5.786-5.347c1.855-1.513,3.723-2.771,5.603-3.772
- c1.879-1,3.809-1.758,5.786-2.27c1.978-0.514,4.065-0.77,6.262-0.77c4.785,0,8.862,0.928,12.231,2.783
- c3.369,1.856,6.116,4.395,8.24,7.617s3.673,6.971,4.651,11.242C61.735,58.154,62.224,62.684,62.224,67.468z M49.7,68.859
- c0-3.369-0.259-6.629-0.773-9.777c-0.516-3.15-1.401-5.944-2.653-8.387c-1.253-2.441-2.936-4.395-5.048-5.859
- c-2.113-1.465-4.742-2.197-7.885-2.197c-1.572,0-3.121,0.232-4.643,0.695c-1.523,0.465-3.071,1.197-4.643,2.197
- c-1.572,1.002-3.218,2.32-4.937,3.955c-1.72,1.637-3.538,3.651-5.453,6.043V81.75c3.34,4.054,6.509,7.154,9.507,9.302
- c2.996,2.149,6.141,3.223,9.432,3.223c3.045,0,5.661-0.732,7.847-2.197c2.186-1.465,3.955-3.417,5.307-5.859
- c1.35-2.44,2.346-5.175,2.984-8.203C49.38,74.988,49.7,71.936,49.7,68.859z"/>
- <path d="M130.046,101.525c0,0.586-0.196,1.025-0.586,1.318c-0.392,0.293-0.928,0.513-1.611,0.659
- c-0.685,0.146-1.685,0.22-3.003,0.22c-1.271,0-2.283-0.073-3.04-0.22c-0.758-0.146-1.307-0.366-1.648-0.659
- c-0.342-0.293-0.513-0.732-0.513-1.318v-6.592c-2.882,3.076-6.092,5.469-9.631,7.178c-3.541,1.709-7.288,2.563-11.243,2.563
- c-3.468,0-6.604-0.452-9.412-1.354c-2.809-0.903-5.2-2.209-7.178-3.919c-1.978-1.708-3.516-3.809-4.614-6.299
- s-1.648-5.321-1.648-8.496c0-3.71,0.756-6.933,2.271-9.668c1.513-2.733,3.686-5.005,6.519-6.812c2.831-1.806,6.299-3.16,10.4-4.064
- c4.102-0.903,8.716-1.355,13.843-1.355h9.082V57.58c0-2.538-0.269-4.785-0.806-6.738c-0.538-1.952-1.404-3.576-2.6-4.871
- c-1.197-1.293-2.747-2.27-4.651-2.93c-1.904-0.658-4.248-0.988-7.031-0.988c-2.979,0-5.652,0.355-8.02,1.063
- c-2.369,0.708-4.444,1.49-6.226,2.344c-1.783,0.854-3.272,1.637-4.468,2.344c-1.197,0.708-2.087,1.062-2.673,1.062
- c-0.392,0-0.732-0.097-1.025-0.293c-0.293-0.194-0.549-0.487-0.769-0.879c-0.22-0.39-0.379-0.89-0.476-1.501
- c-0.099-0.61-0.146-1.282-0.146-2.015c0-1.22,0.084-2.185,0.256-2.894c0.17-0.707,0.586-1.379,1.245-2.014
- c0.659-0.634,1.794-1.379,3.406-2.234c1.611-0.854,3.466-1.635,5.566-2.344c2.099-0.707,4.395-1.293,6.885-1.758
- c2.49-0.463,5.004-0.695,7.544-0.695c4.735,0,8.764,0.538,12.085,1.611c3.32,1.074,6.006,2.649,8.057,4.725
- c2.051,2.076,3.54,4.65,4.468,7.727c0.927,3.076,1.392,6.665,1.392,10.767V101.525z M118.035,71.423h-10.327
- c-3.321,0-6.202,0.282-8.643,0.843c-2.442,0.562-4.468,1.391-6.079,2.49c-1.611,1.098-2.796,2.416-3.552,3.955
- c-0.758,1.537-1.135,3.309-1.135,5.31c0,3.419,1.086,6.142,3.259,8.167c2.172,2.026,5.211,3.039,9.119,3.039
- c3.173,0,6.116-0.806,8.826-2.417s5.554-4.076,8.533-7.397V71.423z"/>
- <path d="M209.001,101.452c0,0.392-0.099,0.722-0.293,0.989c-0.196,0.269-0.513,0.501-0.952,0.695s-1.051,0.341-1.831,0.439
- c-0.782,0.098-1.758,0.146-2.93,0.146c-1.221,0-2.223-0.049-3.003-0.146c-0.782-0.099-1.392-0.245-1.831-0.439
- s-0.758-0.427-0.952-0.695c-0.196-0.268-0.293-0.598-0.293-0.989V62.854c0-3.76-0.293-6.786-0.879-9.082
- c-0.586-2.295-1.441-4.271-2.563-5.933c-1.124-1.659-2.576-2.93-4.358-3.809c-1.783-0.879-3.845-1.318-6.189-1.318
- c-3.028,0-6.055,1.075-9.082,3.223c-3.028,2.149-6.202,5.299-9.521,9.448v46.069c0,0.392-0.099,0.722-0.293,0.989
- c-0.196,0.269-0.513,0.501-0.952,0.695s-1.051,0.341-1.831,0.439c-0.782,0.098-1.783,0.146-3.003,0.146
- c-1.172,0-2.149-0.049-2.93-0.146c-0.782-0.099-1.404-0.245-1.868-0.439c-0.465-0.194-0.782-0.427-0.952-0.695
- c-0.172-0.268-0.256-0.598-0.256-0.989V35.534c0-0.39,0.073-0.72,0.22-0.989c0.146-0.268,0.439-0.512,0.879-0.732
- c0.439-0.219,1-0.365,1.685-0.439c0.683-0.072,1.586-0.109,2.71-0.109c1.073,0,1.965,0.037,2.673,0.109
- c0.707,0.074,1.256,0.221,1.648,0.439c0.39,0.221,0.67,0.465,0.842,0.732c0.17,0.27,0.256,0.6,0.256,0.989v8.716
- c3.71-4.149,7.409-7.189,11.096-9.119c3.686-1.928,7.409-2.893,11.169-2.893c4.395,0,8.093,0.745,11.096,2.234
- c3.003,1.49,5.431,3.479,7.288,5.969c1.855,2.49,3.186,5.408,3.992,8.752c0.806,3.346,1.208,7.361,1.208,12.049V101.452z"/>
- <path d="M278.436,91.418c0,0.831-0.025,1.551-0.074,2.16c-0.049,0.611-0.135,1.125-0.256,1.539
- c-0.123,0.415-0.27,0.781-0.439,1.098c-0.172,0.318-0.563,0.782-1.172,1.393c-0.611,0.611-1.648,1.367-3.113,2.27
- c-1.464,0.904-3.112,1.711-4.943,2.418c-1.831,0.708-3.821,1.281-5.969,1.721c-2.149,0.439-4.371,0.659-6.665,0.659
- c-4.737,0-8.936-0.782-12.598-2.344s-6.727-3.845-9.192-6.849c-2.466-3.002-4.347-6.688-5.64-11.059
- c-1.294-4.369-1.941-9.412-1.941-15.125c0-6.493,0.793-12.072,2.38-16.736c1.586-4.662,3.759-8.482,6.519-11.462
- c2.758-2.978,6.006-5.188,9.741-6.628c3.735-1.439,7.775-2.161,12.122-2.161c2.099,0,4.138,0.196,6.116,0.586
- c1.978,0.392,3.796,0.904,5.457,1.538c1.659,0.635,3.137,1.367,4.432,2.197c1.293,0.831,2.232,1.538,2.818,2.124
- s0.99,1.051,1.209,1.392c0.221,0.342,0.402,0.745,0.549,1.209c0.146,0.465,0.244,0.988,0.293,1.574s0.074,1.318,0.074,2.197
- c0,1.904-0.221,3.235-0.66,3.992c-0.439,0.758-0.977,1.135-1.611,1.135c-0.732,0-1.574-0.402-2.525-1.209
- c-0.954-0.805-2.162-1.695-3.626-2.673c-1.465-0.976-3.235-1.868-5.31-2.673c-2.076-0.807-4.53-1.209-7.361-1.209
- c-5.812,0-10.267,2.234-13.367,6.701c-3.102,4.469-4.651,10.95-4.651,19.446c0,4.248,0.403,7.972,1.208,11.169
- c0.806,3.199,1.989,5.873,3.552,8.021c1.562,2.149,3.479,3.748,5.75,4.798c2.271,1.051,4.871,1.574,7.8,1.574
- c2.783,0,5.224-0.439,7.324-1.318c2.099-0.879,3.918-1.842,5.457-2.893c1.538-1.05,2.831-2.002,3.882-2.857
- c1.049-0.854,1.867-1.281,2.453-1.281c0.342,0,0.635,0.099,0.879,0.293c0.244,0.195,0.451,0.525,0.623,0.988
- c0.17,0.465,0.293,1.051,0.367,1.758C278.398,89.6,278.436,90.441,278.436,91.418z"/>
- <path d="M342.889,101.525c0,0.586-0.195,1.025-0.586,1.318c-0.393,0.293-0.928,0.513-1.611,0.659
- c-0.686,0.146-1.686,0.22-3.004,0.22c-1.27,0-2.283-0.073-3.039-0.22c-0.758-0.146-1.307-0.366-1.648-0.659
- s-0.512-0.732-0.512-1.318v-6.592c-2.883,3.076-6.092,5.469-9.631,7.178c-3.541,1.709-7.289,2.563-11.244,2.563
- c-3.467,0-6.604-0.452-9.41-1.354c-2.809-0.903-5.201-2.209-7.178-3.919c-1.979-1.708-3.516-3.809-4.615-6.299
- c-1.098-2.49-1.648-5.321-1.648-8.496c0-3.71,0.758-6.933,2.271-9.668c1.512-2.733,3.686-5.005,6.518-6.812
- c2.832-1.806,6.299-3.16,10.4-4.064c4.102-0.903,8.717-1.355,13.844-1.355h9.082V57.58c0-2.538-0.27-4.785-0.807-6.738
- c-0.537-1.952-1.404-3.576-2.6-4.871c-1.197-1.293-2.746-2.27-4.65-2.93c-1.904-0.658-4.248-0.988-7.031-0.988
- c-2.979,0-5.652,0.355-8.02,1.063c-2.369,0.708-4.445,1.49-6.227,2.344c-1.783,0.854-3.271,1.637-4.467,2.344
- c-1.197,0.708-2.088,1.062-2.674,1.062c-0.393,0-0.732-0.097-1.025-0.293c-0.293-0.194-0.549-0.487-0.77-0.879
- c-0.219-0.39-0.379-0.89-0.477-1.501c-0.098-0.61-0.146-1.282-0.146-2.015c0-1.22,0.086-2.185,0.258-2.894
- c0.17-0.707,0.586-1.379,1.244-2.014c0.66-0.634,1.795-1.379,3.406-2.234c1.611-0.854,3.467-1.635,5.566-2.344
- c2.098-0.707,4.395-1.293,6.885-1.758c2.49-0.463,5.004-0.695,7.543-0.695c4.736,0,8.764,0.538,12.086,1.611
- c3.32,1.074,6.006,2.649,8.057,4.725c2.051,2.076,3.539,4.65,4.467,7.727s1.393,6.665,1.393,10.767V101.525z M330.877,71.423
- h-10.328c-3.32,0-6.201,0.282-8.643,0.843c-2.441,0.562-4.467,1.391-6.078,2.49c-1.611,1.098-2.797,2.416-3.553,3.955
- c-0.758,1.537-1.135,3.309-1.135,5.31c0,3.419,1.086,6.142,3.26,8.167c2.172,2.026,5.211,3.039,9.117,3.039
- c3.174,0,6.117-0.806,8.826-2.417c2.711-1.611,5.555-4.076,8.533-7.397V71.423z"/>
- <path d="M419.207,101.379c0,0.392-0.1,0.732-0.293,1.025c-0.195,0.293-0.525,0.538-0.988,0.732
- c-0.465,0.194-1.111,0.341-1.941,0.439c-0.832,0.098-1.881,0.146-3.15,0.146c-1.318,0-2.404-0.037-3.258-0.109
- c-0.855-0.074-1.576-0.196-2.162-0.367c-0.586-0.17-1.061-0.414-1.428-0.732c-0.365-0.316-0.695-0.695-0.988-1.135l-27.832-36.475
- v36.548c0,0.392-0.1,0.722-0.293,0.989c-0.195,0.269-0.514,0.501-0.953,0.695s-1.051,0.341-1.83,0.439
- c-0.781,0.098-1.783,0.146-3.004,0.146c-1.172,0-2.148-0.049-2.93-0.146c-0.781-0.099-1.404-0.245-1.867-0.439
- c-0.465-0.194-0.781-0.427-0.951-0.695c-0.172-0.268-0.258-0.598-0.258-0.989V3.601c0-0.39,0.086-0.732,0.258-1.025
- c0.17-0.293,0.486-0.537,0.951-0.732c0.463-0.194,1.086-0.341,1.867-0.439c0.781-0.097,1.758-0.146,2.93-0.146
- c1.221,0,2.223,0.049,3.004,0.146c0.779,0.099,1.391,0.245,1.83,0.439c0.439,0.196,0.758,0.439,0.953,0.732
- c0.193,0.293,0.293,0.636,0.293,1.025V63.22l24.902-27.393c0.391-0.487,0.805-0.89,1.244-1.208
- c0.439-0.317,0.965-0.586,1.576-0.807c0.609-0.219,1.328-0.365,2.16-0.439c0.83-0.072,1.83-0.109,3.002-0.109
- c1.221,0,2.246,0.037,3.076,0.109c0.83,0.074,1.502,0.196,2.016,0.367c0.512,0.172,0.879,0.391,1.098,0.658
- c0.221,0.27,0.33,0.623,0.33,1.063c0,0.586-0.16,1.172-0.477,1.758c-0.318,0.586-0.842,1.271-1.574,2.051l-23.877,23.877
- l26.807,34.79c0.633,0.831,1.086,1.501,1.355,2.015C419.072,100.463,419.207,100.939,419.207,101.379z"/>
- <path d="M484.686,65.637c0,1.904-0.479,3.26-1.436,4.064c-0.957,0.807-2.047,1.209-3.273,1.209h-43.412
- c0,3.662,0.367,6.958,1.104,9.888s1.963,5.445,3.68,7.544c1.717,2.1,3.951,3.711,6.697,4.834c2.748,1.124,6.109,1.685,10.084,1.685
- c3.141,0,5.936-0.257,8.391-0.769c2.453-0.514,4.574-1.086,6.365-1.722c1.791-0.634,3.264-1.208,4.416-1.722
- c1.154-0.512,2.025-0.769,2.615-0.769c0.342,0,0.648,0.086,0.918,0.257c0.27,0.172,0.479,0.428,0.627,0.769
- c0.146,0.343,0.256,0.818,0.33,1.429c0.072,0.611,0.111,1.354,0.111,2.233c0,0.636-0.025,1.185-0.074,1.647
- c-0.049,0.465-0.109,0.879-0.182,1.246c-0.074,0.365-0.197,0.695-0.367,0.988c-0.172,0.293-0.391,0.574-0.658,0.842
- c-0.27,0.27-1.063,0.709-2.381,1.318c-1.318,0.611-3.029,1.209-5.127,1.795c-2.1,0.586-4.529,1.109-7.287,1.574
- c-2.76,0.464-5.703,0.696-8.826,0.696c-5.42,0-10.17-0.758-14.246-2.271c-4.078-1.513-7.508-3.76-10.291-6.738
- c-2.783-2.978-4.883-6.713-6.299-11.206c-1.416-4.491-2.123-9.716-2.123-15.674c0-5.663,0.732-10.754,2.197-15.271
- c1.465-4.516,3.576-8.35,6.336-11.5c2.758-3.148,6.09-5.566,9.996-7.25c3.906-1.686,8.277-2.527,13.111-2.527
- c5.174,0,9.582,0.831,13.221,2.49c3.637,1.66,6.627,3.895,8.971,6.701c2.344,2.809,4.066,6.105,5.164,9.889
- c1.1,3.784,1.648,7.825,1.648,12.121V65.637z M472.527,62.048c0.146-6.347-1.268-11.327-4.238-14.941
- c-2.973-3.612-7.381-5.42-13.227-5.42c-2.998,0-5.627,0.562-7.885,1.685c-2.262,1.124-4.152,2.613-5.676,4.468
- c-1.523,1.856-2.701,4.017-3.537,6.481c-0.836,2.467-1.301,5.043-1.4,7.728H472.527z"/>
- <path d="M518.67,95.3c0,3.468-0.574,5.774-1.721,6.921c-1.148,1.146-3.236,1.722-6.264,1.722c-2.93,0-4.955-0.562-6.078-1.685
- c-1.125-1.123-1.686-3.369-1.686-6.738c0-3.467,0.574-5.773,1.723-6.922c1.146-1.146,3.232-1.721,6.262-1.721
- c2.93,0,4.955,0.563,6.078,1.685C518.107,89.686,518.67,91.931,518.67,95.3z"/>
-</g>
-<g>
-</g>
-<g>
-</g>
-<line fill="none" stroke="#000000" stroke-width="10" stroke-miterlimit="10" x1="270.144" y1="96.144" x2="298.572" y2="73.571"/>
-<line fill="none" stroke="#000000" stroke-width="10" stroke-miterlimit="10" x1="199.429" y1="43" x2="238.001" y2="92.144"/>
-<line fill="none" stroke="#000000" stroke-width="8" stroke-miterlimit="10" x1="123.144" y1="86.429" x2="171.144" y2="42.715"/>
-<line fill="none" stroke="#000000" stroke-width="9" stroke-miterlimit="10" x1="331" y1="66.5" x2="469" y2="66.5"/>
-</svg>
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg version="1.1" baseProfile="tiny" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
+ x="0px" y="0px" width="521px" height="131px" viewBox="0 0 521 131" xml:space="preserve">
+<g>
+ <path d="M62.224,67.468c0,5.763-0.623,10.938-1.868,15.527c-1.245,4.591-3.076,8.485-5.493,11.683
+ c-2.417,3.198-5.409,5.664-8.972,7.396c-3.565,1.732-7.643,2.601-12.231,2.601c-1.954,0-3.761-0.196-5.42-0.586
+ c-1.661-0.392-3.285-1-4.871-1.831c-1.587-0.83-3.162-1.879-4.724-3.149c-1.563-1.269-3.223-2.758-4.98-4.468V127.6
+ c0,0.391-0.099,0.732-0.293,1.025c-0.196,0.293-0.513,0.537-0.952,0.732c-0.439,0.194-1.051,0.341-1.831,0.439
+ c-0.782,0.098-1.783,0.146-3.003,0.146c-1.172,0-2.149-0.049-2.93-0.146c-0.782-0.099-1.404-0.245-1.868-0.439
+ c-0.465-0.195-0.782-0.439-0.952-0.732c-0.172-0.293-0.256-0.635-0.256-1.025V35.534c0-0.439,0.073-0.793,0.22-1.062
+ c0.146-0.268,0.439-0.5,0.879-0.696c0.439-0.194,1-0.329,1.685-0.403c0.683-0.072,1.513-0.109,2.49-0.109
+ c1.025,0,1.868,0.037,2.527,0.109c0.659,0.074,1.208,0.209,1.648,0.403c0.439,0.196,0.744,0.429,0.916,0.696
+ c0.17,0.269,0.256,0.622,0.256,1.062v8.862c2.001-2.051,3.93-3.832,5.786-5.347c1.855-1.513,3.723-2.771,5.603-3.772
+ c1.879-1,3.809-1.758,5.786-2.27c1.978-0.514,4.065-0.77,6.262-0.77c4.785,0,8.862,0.928,12.231,2.783
+ c3.369,1.856,6.116,4.395,8.24,7.617s3.673,6.971,4.651,11.242C61.735,58.154,62.224,62.684,62.224,67.468z M49.7,68.859
+ c0-3.369-0.259-6.629-0.773-9.777c-0.516-3.15-1.401-5.944-2.653-8.387c-1.253-2.441-2.936-4.395-5.048-5.859
+ c-2.113-1.465-4.742-2.197-7.885-2.197c-1.572,0-3.121,0.232-4.643,0.695c-1.523,0.465-3.071,1.197-4.643,2.197
+ c-1.572,1.002-3.218,2.32-4.937,3.955c-1.72,1.637-3.538,3.651-5.453,6.043V81.75c3.34,4.054,6.509,7.154,9.507,9.302
+ c2.996,2.149,6.141,3.223,9.432,3.223c3.045,0,5.661-0.732,7.847-2.197c2.186-1.465,3.955-3.417,5.307-5.859
+ c1.35-2.44,2.346-5.175,2.984-8.203C49.38,74.988,49.7,71.936,49.7,68.859z"/>
+ <path d="M130.046,101.525c0,0.586-0.196,1.025-0.586,1.318c-0.392,0.293-0.928,0.513-1.611,0.659
+ c-0.685,0.146-1.685,0.22-3.003,0.22c-1.271,0-2.283-0.073-3.04-0.22c-0.758-0.146-1.307-0.366-1.648-0.659
+ c-0.342-0.293-0.513-0.732-0.513-1.318v-6.592c-2.882,3.076-6.092,5.469-9.631,7.178c-3.541,1.709-7.288,2.563-11.243,2.563
+ c-3.468,0-6.604-0.452-9.412-1.354c-2.809-0.903-5.2-2.209-7.178-3.919c-1.978-1.708-3.516-3.809-4.614-6.299
+ s-1.648-5.321-1.648-8.496c0-3.71,0.756-6.933,2.271-9.668c1.513-2.733,3.686-5.005,6.519-6.812c2.831-1.806,6.299-3.16,10.4-4.064
+ c4.102-0.903,8.716-1.355,13.843-1.355h9.082V57.58c0-2.538-0.269-4.785-0.806-6.738c-0.538-1.952-1.404-3.576-2.6-4.871
+ c-1.197-1.293-2.747-2.27-4.651-2.93c-1.904-0.658-4.248-0.988-7.031-0.988c-2.979,0-5.652,0.355-8.02,1.063
+ c-2.369,0.708-4.444,1.49-6.226,2.344c-1.783,0.854-3.272,1.637-4.468,2.344c-1.197,0.708-2.087,1.062-2.673,1.062
+ c-0.392,0-0.732-0.097-1.025-0.293c-0.293-0.194-0.549-0.487-0.769-0.879c-0.22-0.39-0.379-0.89-0.476-1.501
+ c-0.099-0.61-0.146-1.282-0.146-2.015c0-1.22,0.084-2.185,0.256-2.894c0.17-0.707,0.586-1.379,1.245-2.014
+ c0.659-0.634,1.794-1.379,3.406-2.234c1.611-0.854,3.466-1.635,5.566-2.344c2.099-0.707,4.395-1.293,6.885-1.758
+ c2.49-0.463,5.004-0.695,7.544-0.695c4.735,0,8.764,0.538,12.085,1.611c3.32,1.074,6.006,2.649,8.057,4.725
+ c2.051,2.076,3.54,4.65,4.468,7.727c0.927,3.076,1.392,6.665,1.392,10.767V101.525z M118.035,71.423h-10.327
+ c-3.321,0-6.202,0.282-8.643,0.843c-2.442,0.562-4.468,1.391-6.079,2.49c-1.611,1.098-2.796,2.416-3.552,3.955
+ c-0.758,1.537-1.135,3.309-1.135,5.31c0,3.419,1.086,6.142,3.259,8.167c2.172,2.026,5.211,3.039,9.119,3.039
+ c3.173,0,6.116-0.806,8.826-2.417s5.554-4.076,8.533-7.397V71.423z"/>
+ <path d="M209.001,101.452c0,0.392-0.099,0.722-0.293,0.989c-0.196,0.269-0.513,0.501-0.952,0.695s-1.051,0.341-1.831,0.439
+ c-0.782,0.098-1.758,0.146-2.93,0.146c-1.221,0-2.223-0.049-3.003-0.146c-0.782-0.099-1.392-0.245-1.831-0.439
+ s-0.758-0.427-0.952-0.695c-0.196-0.268-0.293-0.598-0.293-0.989V62.854c0-3.76-0.293-6.786-0.879-9.082
+ c-0.586-2.295-1.441-4.271-2.563-5.933c-1.124-1.659-2.576-2.93-4.358-3.809c-1.783-0.879-3.845-1.318-6.189-1.318
+ c-3.028,0-6.055,1.075-9.082,3.223c-3.028,2.149-6.202,5.299-9.521,9.448v46.069c0,0.392-0.099,0.722-0.293,0.989
+ c-0.196,0.269-0.513,0.501-0.952,0.695s-1.051,0.341-1.831,0.439c-0.782,0.098-1.783,0.146-3.003,0.146
+ c-1.172,0-2.149-0.049-2.93-0.146c-0.782-0.099-1.404-0.245-1.868-0.439c-0.465-0.194-0.782-0.427-0.952-0.695
+ c-0.172-0.268-0.256-0.598-0.256-0.989V35.534c0-0.39,0.073-0.72,0.22-0.989c0.146-0.268,0.439-0.512,0.879-0.732
+ c0.439-0.219,1-0.365,1.685-0.439c0.683-0.072,1.586-0.109,2.71-0.109c1.073,0,1.965,0.037,2.673,0.109
+ c0.707,0.074,1.256,0.221,1.648,0.439c0.39,0.221,0.67,0.465,0.842,0.732c0.17,0.27,0.256,0.6,0.256,0.989v8.716
+ c3.71-4.149,7.409-7.189,11.096-9.119c3.686-1.928,7.409-2.893,11.169-2.893c4.395,0,8.093,0.745,11.096,2.234
+ c3.003,1.49,5.431,3.479,7.288,5.969c1.855,2.49,3.186,5.408,3.992,8.752c0.806,3.346,1.208,7.361,1.208,12.049V101.452z"/>
+ <path d="M278.436,91.418c0,0.831-0.025,1.551-0.074,2.16c-0.049,0.611-0.135,1.125-0.256,1.539
+ c-0.123,0.415-0.27,0.781-0.439,1.098c-0.172,0.318-0.563,0.782-1.172,1.393c-0.611,0.611-1.648,1.367-3.113,2.27
+ c-1.464,0.904-3.112,1.711-4.943,2.418c-1.831,0.708-3.821,1.281-5.969,1.721c-2.149,0.439-4.371,0.659-6.665,0.659
+ c-4.737,0-8.936-0.782-12.598-2.344s-6.727-3.845-9.192-6.849c-2.466-3.002-4.347-6.688-5.64-11.059
+ c-1.294-4.369-1.941-9.412-1.941-15.125c0-6.493,0.793-12.072,2.38-16.736c1.586-4.662,3.759-8.482,6.519-11.462
+ c2.758-2.978,6.006-5.188,9.741-6.628c3.735-1.439,7.775-2.161,12.122-2.161c2.099,0,4.138,0.196,6.116,0.586
+ c1.978,0.392,3.796,0.904,5.457,1.538c1.659,0.635,3.137,1.367,4.432,2.197c1.293,0.831,2.232,1.538,2.818,2.124
+ s0.99,1.051,1.209,1.392c0.221,0.342,0.402,0.745,0.549,1.209c0.146,0.465,0.244,0.988,0.293,1.574s0.074,1.318,0.074,2.197
+ c0,1.904-0.221,3.235-0.66,3.992c-0.439,0.758-0.977,1.135-1.611,1.135c-0.732,0-1.574-0.402-2.525-1.209
+ c-0.954-0.805-2.162-1.695-3.626-2.673c-1.465-0.976-3.235-1.868-5.31-2.673c-2.076-0.807-4.53-1.209-7.361-1.209
+ c-5.812,0-10.267,2.234-13.367,6.701c-3.102,4.469-4.651,10.95-4.651,19.446c0,4.248,0.403,7.972,1.208,11.169
+ c0.806,3.199,1.989,5.873,3.552,8.021c1.562,2.149,3.479,3.748,5.75,4.798c2.271,1.051,4.871,1.574,7.8,1.574
+ c2.783,0,5.224-0.439,7.324-1.318c2.099-0.879,3.918-1.842,5.457-2.893c1.538-1.05,2.831-2.002,3.882-2.857
+ c1.049-0.854,1.867-1.281,2.453-1.281c0.342,0,0.635,0.099,0.879,0.293c0.244,0.195,0.451,0.525,0.623,0.988
+ c0.17,0.465,0.293,1.051,0.367,1.758C278.398,89.6,278.436,90.441,278.436,91.418z"/>
+ <path d="M342.889,101.525c0,0.586-0.195,1.025-0.586,1.318c-0.393,0.293-0.928,0.513-1.611,0.659
+ c-0.686,0.146-1.686,0.22-3.004,0.22c-1.27,0-2.283-0.073-3.039-0.22c-0.758-0.146-1.307-0.366-1.648-0.659
+ s-0.512-0.732-0.512-1.318v-6.592c-2.883,3.076-6.092,5.469-9.631,7.178c-3.541,1.709-7.289,2.563-11.244,2.563
+ c-3.467,0-6.604-0.452-9.41-1.354c-2.809-0.903-5.201-2.209-7.178-3.919c-1.979-1.708-3.516-3.809-4.615-6.299
+ c-1.098-2.49-1.648-5.321-1.648-8.496c0-3.71,0.758-6.933,2.271-9.668c1.512-2.733,3.686-5.005,6.518-6.812
+ c2.832-1.806,6.299-3.16,10.4-4.064c4.102-0.903,8.717-1.355,13.844-1.355h9.082V57.58c0-2.538-0.27-4.785-0.807-6.738
+ c-0.537-1.952-1.404-3.576-2.6-4.871c-1.197-1.293-2.746-2.27-4.65-2.93c-1.904-0.658-4.248-0.988-7.031-0.988
+ c-2.979,0-5.652,0.355-8.02,1.063c-2.369,0.708-4.445,1.49-6.227,2.344c-1.783,0.854-3.271,1.637-4.467,2.344
+ c-1.197,0.708-2.088,1.062-2.674,1.062c-0.393,0-0.732-0.097-1.025-0.293c-0.293-0.194-0.549-0.487-0.77-0.879
+ c-0.219-0.39-0.379-0.89-0.477-1.501c-0.098-0.61-0.146-1.282-0.146-2.015c0-1.22,0.086-2.185,0.258-2.894
+ c0.17-0.707,0.586-1.379,1.244-2.014c0.66-0.634,1.795-1.379,3.406-2.234c1.611-0.854,3.467-1.635,5.566-2.344
+ c2.098-0.707,4.395-1.293,6.885-1.758c2.49-0.463,5.004-0.695,7.543-0.695c4.736,0,8.764,0.538,12.086,1.611
+ c3.32,1.074,6.006,2.649,8.057,4.725c2.051,2.076,3.539,4.65,4.467,7.727s1.393,6.665,1.393,10.767V101.525z M330.877,71.423
+ h-10.328c-3.32,0-6.201,0.282-8.643,0.843c-2.441,0.562-4.467,1.391-6.078,2.49c-1.611,1.098-2.797,2.416-3.553,3.955
+ c-0.758,1.537-1.135,3.309-1.135,5.31c0,3.419,1.086,6.142,3.26,8.167c2.172,2.026,5.211,3.039,9.117,3.039
+ c3.174,0,6.117-0.806,8.826-2.417c2.711-1.611,5.555-4.076,8.533-7.397V71.423z"/>
+ <path d="M419.207,101.379c0,0.392-0.1,0.732-0.293,1.025c-0.195,0.293-0.525,0.538-0.988,0.732
+ c-0.465,0.194-1.111,0.341-1.941,0.439c-0.832,0.098-1.881,0.146-3.15,0.146c-1.318,0-2.404-0.037-3.258-0.109
+ c-0.855-0.074-1.576-0.196-2.162-0.367c-0.586-0.17-1.061-0.414-1.428-0.732c-0.365-0.316-0.695-0.695-0.988-1.135l-27.832-36.475
+ v36.548c0,0.392-0.1,0.722-0.293,0.989c-0.195,0.269-0.514,0.501-0.953,0.695s-1.051,0.341-1.83,0.439
+ c-0.781,0.098-1.783,0.146-3.004,0.146c-1.172,0-2.148-0.049-2.93-0.146c-0.781-0.099-1.404-0.245-1.867-0.439
+ c-0.465-0.194-0.781-0.427-0.951-0.695c-0.172-0.268-0.258-0.598-0.258-0.989V3.601c0-0.39,0.086-0.732,0.258-1.025
+ c0.17-0.293,0.486-0.537,0.951-0.732c0.463-0.194,1.086-0.341,1.867-0.439c0.781-0.097,1.758-0.146,2.93-0.146
+ c1.221,0,2.223,0.049,3.004,0.146c0.779,0.099,1.391,0.245,1.83,0.439c0.439,0.196,0.758,0.439,0.953,0.732
+ c0.193,0.293,0.293,0.636,0.293,1.025V63.22l24.902-27.393c0.391-0.487,0.805-0.89,1.244-1.208
+ c0.439-0.317,0.965-0.586,1.576-0.807c0.609-0.219,1.328-0.365,2.16-0.439c0.83-0.072,1.83-0.109,3.002-0.109
+ c1.221,0,2.246,0.037,3.076,0.109c0.83,0.074,1.502,0.196,2.016,0.367c0.512,0.172,0.879,0.391,1.098,0.658
+ c0.221,0.27,0.33,0.623,0.33,1.063c0,0.586-0.16,1.172-0.477,1.758c-0.318,0.586-0.842,1.271-1.574,2.051l-23.877,23.877
+ l26.807,34.79c0.633,0.831,1.086,1.501,1.355,2.015C419.072,100.463,419.207,100.939,419.207,101.379z"/>
+ <path d="M484.686,65.637c0,1.904-0.479,3.26-1.436,4.064c-0.957,0.807-2.047,1.209-3.273,1.209h-43.412
+ c0,3.662,0.367,6.958,1.104,9.888s1.963,5.445,3.68,7.544c1.717,2.1,3.951,3.711,6.697,4.834c2.748,1.124,6.109,1.685,10.084,1.685
+ c3.141,0,5.936-0.257,8.391-0.769c2.453-0.514,4.574-1.086,6.365-1.722c1.791-0.634,3.264-1.208,4.416-1.722
+ c1.154-0.512,2.025-0.769,2.615-0.769c0.342,0,0.648,0.086,0.918,0.257c0.27,0.172,0.479,0.428,0.627,0.769
+ c0.146,0.343,0.256,0.818,0.33,1.429c0.072,0.611,0.111,1.354,0.111,2.233c0,0.636-0.025,1.185-0.074,1.647
+ c-0.049,0.465-0.109,0.879-0.182,1.246c-0.074,0.365-0.197,0.695-0.367,0.988c-0.172,0.293-0.391,0.574-0.658,0.842
+ c-0.27,0.27-1.063,0.709-2.381,1.318c-1.318,0.611-3.029,1.209-5.127,1.795c-2.1,0.586-4.529,1.109-7.287,1.574
+ c-2.76,0.464-5.703,0.696-8.826,0.696c-5.42,0-10.17-0.758-14.246-2.271c-4.078-1.513-7.508-3.76-10.291-6.738
+ c-2.783-2.978-4.883-6.713-6.299-11.206c-1.416-4.491-2.123-9.716-2.123-15.674c0-5.663,0.732-10.754,2.197-15.271
+ c1.465-4.516,3.576-8.35,6.336-11.5c2.758-3.148,6.09-5.566,9.996-7.25c3.906-1.686,8.277-2.527,13.111-2.527
+ c5.174,0,9.582,0.831,13.221,2.49c3.637,1.66,6.627,3.895,8.971,6.701c2.344,2.809,4.066,6.105,5.164,9.889
+ c1.1,3.784,1.648,7.825,1.648,12.121V65.637z M472.527,62.048c0.146-6.347-1.268-11.327-4.238-14.941
+ c-2.973-3.612-7.381-5.42-13.227-5.42c-2.998,0-5.627,0.562-7.885,1.685c-2.262,1.124-4.152,2.613-5.676,4.468
+ c-1.523,1.856-2.701,4.017-3.537,6.481c-0.836,2.467-1.301,5.043-1.4,7.728H472.527z"/>
+ <path d="M518.67,95.3c0,3.468-0.574,5.774-1.721,6.921c-1.148,1.146-3.236,1.722-6.264,1.722c-2.93,0-4.955-0.562-6.078-1.685
+ c-1.125-1.123-1.686-3.369-1.686-6.738c0-3.467,0.574-5.773,1.723-6.922c1.146-1.146,3.232-1.721,6.262-1.721
+ c2.93,0,4.955,0.563,6.078,1.685C518.107,89.686,518.67,91.931,518.67,95.3z"/>
+</g>
+<g>
+</g>
+<g>
+</g>
+<line fill="none" stroke="#000000" stroke-width="10" stroke-miterlimit="10" x1="270.144" y1="96.144" x2="298.572" y2="73.571"/>
+<line fill="none" stroke="#000000" stroke-width="10" stroke-miterlimit="10" x1="199.429" y1="43" x2="238.001" y2="92.144"/>
+<line fill="none" stroke="#000000" stroke-width="8" stroke-miterlimit="10" x1="123.144" y1="86.429" x2="171.144" y2="42.715"/>
+<line fill="none" stroke="#000000" stroke-width="9" stroke-miterlimit="10" x1="331" y1="66.5" x2="469" y2="66.5"/>
+</svg>
View
682 sys/AJP13.class.php
@@ -1,342 +1,342 @@
-<?php
-
- /****************************************************************/
- /* Pancake */
- /* AJP13.class.php */
- /* 2012 - 2013 Yussuf Khalil */
- /* License: http://pancakehttp.net/license/ */
- /****************************************************************/
-
- #.if 0
- namespace Pancake;
-
- if(PANCAKE !== true)
- exit;
- #.endif
-
- #.AJP13_HTTP_OPTIONS = "\x1"
- #.AJP13_HTTP_GET = "\x2"
- #.AJP13_HTTP_HEAD = "\x3"
- #.AJP13_HTTP_POST = "\x4"
-
- #.AJP13_FORWARD_REQUEST = "\x2"
-
- #.AJP13_SEND_BODY_CHUNK = "\x3"
- #.AJP13_SEND_HEADERS = "\x4"
- #.AJP13_END_RESPONSE = "\x5"
- #.AJP13_GET_BODY_CHUNK = "\x6"
- #.AJP13_CPONG = "\x9"
-
- #.AJP13_APPEND_DATA = 1048576
-
- class AJP13 {
- private static $instances = array();
- private $sockets = array();
- private $freeSockets = array();
- private $address = "";
- private $port = 0;
- private $type = "";
- private $maxConcurrent = null;
- private $requests = array();
- private $requestSockets = array();
-
- public static function getInstance($name) {
- if(!isset(self::$instances[$name]))
- self::$instances[$name] = new self($name);
- return self::$instances[$name];
- }
-
- private function __construct($name) {
- $config = Config::get('ajp13.' . $name);
-
- if(!$config)
- throw new \Exception('Undefined AJP13 configuration: ' . $name);
-
- $this->address = $config['address'];
- $this->port = $config['port'];
- $this->type = strtolower($config['type']);
- if($config['maxconcurrent'])
- $this->maxConcurrent = (int) $config['maxconcurrent'];
- }
-
- private function connect() {
- if($this->maxConcurrent && count($this->sockets) >= $this->maxConcurrent)
- return false;
-
- switch($this->type) {
- case 'ipv6':
- $socket = socket_create(/* .constant 'AF_INET6' */, /* .constant 'SOCK_STREAM' */, /* .constant 'SOL_TCP' */);
- if(!socket_connect($socket, $this->address, $this->port)) {
- trigger_error('Unable to connect to AJP13 upstream server at ipv6:' . $this->address . ':' . $this->port, /* .constant 'E_USER_ERROR' */);
- return false;
- }
- break;
- case 'ipv4':
- $socket = socket_create(/* .constant 'AF_INET' */, /* .constant 'SOCK_STREAM' */, /* .constant 'SOL_TCP' */);
- if(!socket_connect($socket, $this->address, $this->port)) {
- trigger_error('Unable to connect to AJP13 upstream server at ipv4:' . $this->address . ':' . $this->port, /* .constant 'E_USER_ERROR' */);
- return false;
- }
- break;
- default:
- $socket = socket_create(/* .constant 'AF_UNIX' */, /* .constant 'SOCK_STREAM' */, 0);
- if(!socket_connect($socket, $this->address)) {
- trigger_error('Unable to connect to AJP13 upstream server at unix:' . $this->address, /* .constant 'E_USER_ERROR' */);
- return false;
- }
- }
-
- socket_set_option($socket, /* .constant 'SOL_SOCKET' */, /* .constant 'SO_KEEPALIVE' */, 1);
- $this->sockets[(int) $socket] = $socket;
- return $socket;
- }
-
- public function makeRequest(HTTPRequest $requestObject, $requestSocket) {
- if($this->freeSockets) {
- foreach($this->freeSockets as $id => $socket) {
- unset($this->freeSockets[$id]);
- break;
- }
- } else if(!($socket = $this->connect())) {
- $requestObject->invalidRequest(new invalidHTTPRequestException('Failed to connect to AJP13 upstream server', 502));
- return false;
- }
-
- switch($requestObject->requestType) {
- case 'GET':
- $method = /* .AJP13_HTTP_GET */;
- break;
- case 'POST':
- $method = /* .AJP13_HTTP_POST */;
- break;
- #.if true === #.Pancake\Config::get('main.allowhead')
- case 'HEAD':
- $method = /* .AJP13_HTTP_HEAD */;
- break;
- #.endif
- #.if true === #.Pancake\Config::get('main.allowoptions')
- case 'OPTIONS':
- $method = /* .AJP13_HTTP_OPTIONS */;
- #.endif
- }
-
- $strlenURI = strlen($requestObject->requestURI);
- $strlenAddr = strlen($requestObject->remoteIP);
- $strlenServerName = strlen($requestObject->vHost->listen[0]);
- $headers = "";
- $headerCount = 0;
-
- foreach($requestObject->requestHeaders as $headerName => $headerValue) {
- $strlenValue = strlen($headerValue);
- switch(strtolower($headerName)) {
- case 'accept':
- $headers .= "\xa0\x01";
- break;
- case 'accept-charset':
- $headers .= "\xa0\x02";
- break;
- case 'accept-encoding':
- $headers .= "\xa0\x03";
- break;
- case 'accept-language':
- $headers .= "\xa0\x04";
- break;
- case 'authorization':
- $headers .= "\xa0\x05";
- break;
- case 'connection':
- $headers .= "\xa0\x06";
- break;
- case 'content-type':
- $headers .= "\xa0\x07";
- break;
- case 'content-length':
- $headers .= "\xa0\x08";
- break;
- case 'cookie':
- $headers .= "\xa0\x09";
- break;
- /* cookie2? */
- case 'host':
- $headers .= "\xa0\x0b";
- break;
- case 'pragma':
- $headers .= "\xa0\x0c";
- break;
- case 'referer':
- case 'referrer':
- $headers .= "\xa0\x0d";
- break;
- case 'user-agent':
- $headers .= "\xa0\x0e";
- break;
- default:
- $strlenHeaderName = strlen($headerName);
- $headers .= chr($strlenHeaderName >> 8) . chr($strlenHeaderName) . $headerName . "\x0";
- }
- $headerCount++;
- $strlenValue = strlen($headerValue);
- $headers .= chr($strlenValue >> 8) . chr($strlenValue) . $headerValue . "\x0";
- }
-
- $body = $method // method byte
- . "\x0\x8HTTP/" . $requestObject->protocolVersion . "\x0" // protocol string + terminating \0
- . chr($strlenURI >> 8) . chr($strlenURI) . $requestObject->requestURI . "\x0" // URI string + terminating \0
- . chr($strlenAddr >> 8) . chr($strlenAddr) . $requestObject->remoteIP . "\x0" // Remote addr string + terminating \0
- . chr($strlenAddr >> 8) . chr($strlenAddr) . $requestObject->remoteIP . "\x0" // Remote host string + terminating \0 - I send the IP address again for performance reasons
- . chr($strlenServerName >> 8) . chr($strlenServerName) . $requestObject->vHost->listen[0] . "\x0" // Server name string + terminating \0
- . chr($requestObject->localPort >> 8) . chr($requestObject->localPort) // Local port integer
- . "\x0" // Is SSL? boolean
- . chr($headerCount >> 8) . chr($headerCount) // Header count integer
- . $headers;
-
- $strlenBody = strlen($body) + 2;
-
- doWrite:
- if(socket_write($socket, "\x12\x34" . chr($strlenBody >> 8) . chr($strlenBody) . "\x02" . $body . "\xff") === false) {
- unset($this->sockets[(int) $socket]);
- if($this->freeSockets) {
- foreach($this->freeSockets as $id => $socket) {
- unset($this->freeSockets[$id]);
- break;
- }
- goto doWrite;
- } else if(!($socket = $this->connect())) {
- $requestObject->invalidRequest(new invalidHTTPRequestException('Failed to connect to AJP13 upstream server', 502));
- return false;
- }
- }
-
- if($requestObject->rawPOSTData) {
- $string = substr($requestObject->rawPOSTData, 0, 8186);
- $strlen = strlen($string);
- socket_write($socket, "\x12\x34" . chr(($strlen + 2) >> 8) . chr($strlen + 2) . chr($strlen >> 8) . chr($strlen) . $string);
- $requestObject->rawPOSTData = substr($requestObject->rawPOSTData, $strlen);
- }
-
- $this->requests[(int) $socket] = $requestObject;
- $this->requestSockets[(int) $socket] = $requestSocket;
-
- return $socket;
- }
-
- public function upstreamRecord($data, $socket) {
- $socketID = (int) $socket;
- $requestObject = $this->requests[$socketID];
-
- if($data === "") {
- /* Upstream server closed connection */
-
- if($requestObject) {
- $requestObject->invalidRequest(new invalidHTTPRequestException("The AJP13 upstream server unexpectedly closed the network connection.", 502));
-
- $retval = array($this->requestSockets[$socketID], $requestObject);
- unset($this->requestSockets[$socketID], $this->requests[$socketID]);
- unset($this->sockets[$socketID], $this->freeSockets[$socketID]);
- return $retval;
- }
-
- $this->connect();
- return 0;
- }
-
- if(strlen($data) < 5)
- return /* .AJP13_APPEND_DATA */ | (5 - strlen($data));
-
- $contentLength = (ord($data[2]) << 8) + ord($data[3]);
-
- if(strlen($data) < $contentLength + 4)
- return /* .AJP13_APPEND_DATA */ | ($contentLength + 4 - strlen($data));
-
- switch($data[4]) {
- case /* .AJP13_GET_BODY_CHUNK */:
- $length = (ord($data[5]) << 8) + ord($data[6]);
- #.ifdef 'USE_IOCACHE'
-
- #.else
- if($requestObject->rawPOSTData) {
- $string = substr($requestObject->rawPOSTData, 0, $length);
- $strlen = strlen($string);
- socket_write($socket, "\x12\x34" . chr(($strlen + 2) >> 8) . chr($strlen + 2) . chr($strlen >> 8) . chr($strlen) . $string);
- $requestObject->rawPOSTData = substr($requestObject->rawPOSTData, $strlen);
- } else
- socket_write($socket, "\x12\x34\x0\x0");
- #.endif
- return 5;
- case /* .AJP13_SEND_BODY_CHUNK */:
- $requestObject->answerBody .= substr($data, 7, (ord($data[5]) << 8) + ord($data[6]));
- return 5;
- case /* .AJP13_END_RESPONSE */:
- if($data[5] == "\x01") {
- $this->freeSockets[$socketID] = $socket;
- } else {
- @socket_shutdown($socket);
- socket_close($socket);
- unset($this->sockets[$socketID]);
- }
- $retval = array($this->requestSockets[$socketID], $requestObject);
- unset($this->requestSockets[$socketID], $this->requests[$socketID]);
- return $retval;
- case /* .AJP13_SEND_HEADERS */:
- // Get HTTP status code
- $requestObject->answerCode = (ord($data[5]) << 8) + ord($data[6]);
-
- // Read headers
- $pos = 12 + (ord($data[7]) << 8) + ord($data[8]);
- $totalLength = $contentLength + 4;
- while($pos < $totalLength) {
- if($data[$pos] == "\xa0") {
- $valueLength = (ord($data[$pos + 2]) << 8) + ord($data[$pos + 3]);
- $value = substr($data, $pos + 4, $valueLength);
- switch($data[$pos + 1]) {
- case "\x01":
- $requestObject->setHeader('Content-Type', $value);
- break;
- case "\x02":
- $requestObject->setHeader('Content-Language', $value);
- break;
- case "\x03":
- $requestObject->setHeader('Content-Length', $value);
- break;
- case "\x04":
- $requestObject->setHeader('Date', $value);
- break;
- case "\x05":
- $requestObject->setHeader('Last-Modified', $value);
- break;
- case "\x06":
- $requestObject->setHeader('Location', $value);
- break;
- case "\x07":
- $requestObject->setHeader('Set-Cookie', $value);
- break;
- case "\x08":
- $requestObject->setHeader('Set-Cookie2', $value);
- break;
- case "\x09":
- $requestObject->setHeader('Servlet-Engine', $value);
- break;
- case "\x0a":
- $requestObject->setHeader('Status', $value);
- break;
- case "\x0b":
- $requestObject->setHeader('WWW-Authenticate', $value);
- break;
- }
-
- $pos += $valueLength + 5;
- } else {
- $headerLength = (ord($data[$pos]) << 8) + ord($data[$pos + 1]);
- $headerName = substr($data, $pos + 2, $headerLength);
- $pos += $headerLength + 3;
- $valueLength = (ord($data[$pos]) << 8) + ord($data[$pos + 1]);
- $value = substr($data, $pos + 2, $valueLength);
- $requestObject->setHeader($headerName, $value);
- $pos += $valueLength + 3;
- }
- }
- return 5;
- }
- }
- }
+<?php
+
+ /****************************************************************/
+ /* Pancake */
+ /* AJP13.class.php */
+ /* 2012 - 2013 Yussuf Khalil */
+ /* License: http://pancakehttp.net/license/ */
+ /****************************************************************/
+
+ #.if 0
+ namespace Pancake;
+
+ if(PANCAKE !== true)
+ exit;
+ #.endif
+
+ #.AJP13_HTTP_OPTIONS = "\x1"
+ #.AJP13_HTTP_GET = "\x2"
+ #.AJP13_HTTP_HEAD = "\x3"
+ #.AJP13_HTTP_POST = "\x4"
+
+ #.AJP13_FORWARD_REQUEST = "\x2"
+
+ #.AJP13_SEND_BODY_CHUNK = "\x3"
+ #.AJP13_SEND_HEADERS = "\x4"
+ #.AJP13_END_RESPONSE = "\x5"
+ #.AJP13_GET_BODY_CHUNK = "\x6"
+ #.AJP13_CPONG = "\x9"
+
+ #.AJP13_APPEND_DATA = 1048576
+
+ class AJP13 {
+ private static $instances = array();
+ private $sockets = array();
+ private $freeSockets = array();
+ private $address = "";
+ private $port = 0;
+ private $type = "";
+ private $maxConcurrent = null;
+ private $requests = array();
+ private $requestSockets = array();
+
+ public static function getInstance($name) {
+ if(!isset(self::$instances[$name]))
+ self::$instances[$name] = new self($name);
+ return self::$instances[$name];
+ }
+
+ private function __construct($name) {
+ $config = Config::get('ajp13.' . $name);
+
+ if(!$config)
+ throw new \Exception('Undefined AJP13 configuration: ' . $name);
+
+ $this->address = $config['address'];
+ $this->port = $config['port'];
+ $this->type = strtolower($config['type']);
+ if($config['maxconcurrent'])
+ $this->maxConcurrent = (int) $config['maxconcurrent'];
+ }
+
+ private function connect() {
+ if($this->maxConcurrent && count($this->sockets) >= $this->maxConcurrent)
+ return false;
+
+ switch($this->type) {
+ case 'ipv6':
+ $socket = socket_create(/* .constant 'AF_INET6' */, /* .constant 'SOCK_STREAM' */, /* .constant 'SOL_TCP' */);
+ if(!socket_connect($socket, $this->address, $this->port)) {
+ trigger_error('Unable to connect to AJP13 upstream server at ipv6:' . $this->address . ':' . $this->port, /* .constant 'E_USER_ERROR' */);
+ return false;
+ }
+ break;
+ case 'ipv4':
+ $socket = socket_create(/* .constant 'AF_INET' */, /* .constant 'SOCK_STREAM' */, /* .constant 'SOL_TCP' */);
+ if(!socket_connect($socket, $this->address, $this->port)) {
+ trigger_error('Unable to connect to AJP13 upstream server at ipv4:' . $this->address . ':' . $this->port, /* .constant 'E_USER_ERROR' */);
+ return false;
+ }
+ break;
+ default:
+ $socket = socket_create(/* .constant 'AF_UNIX' */, /* .constant 'SOCK_STREAM' */, 0);
+ if(!socket_connect($socket, $this->address)) {
+ trigger_error('Unable to connect to AJP13 upstream server at unix:' . $this->address, /* .constant 'E_USER_ERROR' */);
+ return false;
+ }
+ }
+
+ socket_set_option($socket, /* .constant 'SOL_SOCKET' */, /* .constant 'SO_KEEPALIVE' */, 1);
+ $this->sockets[(int) $socket] = $socket;
+ return $socket;
+ }
+
+ public function makeRequest(HTTPRequest $requestObject, $requestSocket) {
+ if($this->freeSockets) {
+ foreach($this->freeSockets as $id => $socket) {
+ unset($this->freeSockets[$id]);
+ break;
+ }
+ } else if(!($socket = $this->connect())) {
+ $requestObject->invalidRequest(new invalidHTTPRequestException('Failed to connect to AJP13 upstream server', 502));
+ return false;
+ }
+
+ switch($requestObject->requestType) {
+ case 'GET':
+ $method = /* .AJP13_HTTP_GET */;
+ break;
+ case 'POST':
+ $method = /* .AJP13_HTTP_POST */;
+ break;
+ #.if true === #.Pancake\Config::get('main.allowhead')
+ case 'HEAD':
+ $method = /* .AJP13_HTTP_HEAD */;
+ break;
+ #.endif
+ #.if true === #.Pancake\Config::get('main.allowoptions')
+ case 'OPTIONS':
+ $method = /* .AJP13_HTTP_OPTIONS */;
+ #.endif
+ }
+
+ $strlenURI = strlen($requestObject->requestURI);
+ $strlenAddr = strlen($requestObject->remoteIP);
+ $strlenServerName = strlen($requestObject->vHost->listen[0]);
+ $headers = "";
+ $headerCount = 0;
+
+ foreach($requestObject->requestHeaders as $headerName => $headerValue) {
+ $strlenValue = strlen($headerValue);
+ switch(strtolower($headerName)) {
+ case 'accept':
+ $headers .= "\xa0\x01";
+ break;
+ case 'accept-charset':
+ $headers .= "\xa0\x02";
+ break;
+ case 'accept-encoding':
+ $headers .= "\xa0\x03";
+ break;
+ case 'accept-language':
+ $headers .= "\xa0\x04";
+ break;
+ case 'authorization':
+ $headers .= "\xa0\x05";
+ break;
+ case 'connection':
+ $headers .= "\xa0\x06";
+ break;
+ case 'content-type':
+ $headers .= "\xa0\x07";
+ break;
+ case 'content-length':
+ $headers .= "\xa0\x08";
+ break;
+ case 'cookie':
+ $headers .= "\xa0\x09";
+ break;
+ /* cookie2? */
+ case 'host':
+ $headers .= "\xa0\x0b";
+ break;
+ case 'pragma':
+ $headers .= "\xa0\x0c";
+ break;
+ case 'referer':
+ case 'referrer':
+ $headers .= "\xa0\x0d";
+ break;
+ case 'user-agent':
+ $headers .= "\xa0\x0e";
+ break;
+ default:
+ $strlenHeaderName = strlen($headerName);
+ $headers .= chr($strlenHeaderName >> 8) . chr($strlenHeaderName) . $headerName . "\x0";
+ }
+ $headerCount++;
+ $strlenValue = strlen($headerValue);
+ $headers .= chr($strlenValue >> 8) . chr($strlenValue) . $headerValue . "\x0";
+ }
+
+ $body = $method // method byte
+ . "\x0\x8HTTP/" . $requestObject->protocolVersion . "\x0" // protocol string + terminating \0
+ . chr($strlenURI >> 8) . chr($strlenURI) . $requestObject->requestURI . "\x0" // URI string + terminating \0
+ . chr($strlenAddr >> 8) . chr($strlenAddr) . $requestObject->remoteIP . "\x0" // Remote addr string + terminating \0
+ . chr($strlenAddr >> 8) . chr($strlenAddr) . $requestObject->remoteIP . "\x0" // Remote host string + terminating \0 - I send the IP address again for performance reasons
+ . chr($strlenServerName >> 8) . chr($strlenServerName) . $requestObject->vHost->listen[0] . "\x0" // Server name string + terminating \0
+ . chr($requestObject->localPort >> 8) . chr($requestObject->localPort) // Local port integer
+ . "\x0" // Is SSL? boolean
+ . chr($headerCount >> 8) . chr($headerCount) // Header count integer
+ . $headers;
+
+ $strlenBody = strlen($body) + 2;
+
+ doWrite:
+ if(socket_write($socket, "\x12\x34" . chr($strlenBody >> 8) . chr($strlenBody) . "\x02" . $body . "\xff") === false) {
+ unset($this->sockets[(int) $socket]);
+ if($this->freeSockets) {
+ foreach($this->freeSockets as $id => $socket) {
+ unset($this->freeSockets[$id]);
+ break;
+ }
+ goto doWrite;
+ } else if(!($socket = $this->connect())) {
+ $requestObject->invalidRequest(new invalidHTTPRequestException('Failed to connect to AJP13 upstream server', 502));
+ return false;
+ }
+ }
+
+ if($requestObject->rawPOSTData) {
+ $string = substr($requestObject->rawPOSTData, 0, 8186);
+ $strlen = strlen($string);
+ socket_write($socket, "\x12\x34" . chr(($strlen + 2) >> 8) . chr($strlen + 2) . chr($strlen >> 8) . chr($strlen) . $string);
+ $requestObject->rawPOSTData = substr($requestObject->rawPOSTData, $strlen);
+ }
+
+ $this->requests[(int) $socket] = $requestObject;
+ $this->requestSockets[(int) $socket] = $requestSocket;
+
+ return $socket;
+ }
+
+ public function upstreamRecord($data, $socket) {
+ $socketID = (int) $socket;
+ $requestObject = $this->requests[$socketID];
+
+ if($data === "") {
+ /* Upstream server closed connection */
+
+ if($requestObject) {
+ $requestObject->invalidRequest(new invalidHTTPRequestException("The AJP13 upstream server unexpectedly closed the network connection.", 502));
+
+ $retval = array($this->requestSockets[$socketID], $requestObject);
+ unset($this->requestSockets[$socketID], $this->requests[$socketID]);
+ unset($this->sockets[$socketID], $this->freeSockets[$socketID]);
+ return $retval;
+ }
+
+ $this->connect();
+ return 0;
+ }
+
+ if(strlen($data) < 5)
+ return /* .AJP13_APPEND_DATA */ | (5 - strlen($data));
+
+ $contentLength = (ord($data[2]) << 8) + ord($data[3]);
+
+ if(strlen($data) < $contentLength + 4)
+ return /* .AJP13_APPEND_DATA */ | ($contentLength + 4 - strlen($data));
+
+ switch($data[4]) {
+ case /* .AJP13_GET_BODY_CHUNK */:
+ $length = (ord($data[5]) << 8) + ord($data[6]);
+ #.ifdef 'USE_IOCACHE'
+
+ #.else
+ if($requestObject->rawPOSTData) {
+ $string = substr($requestObject->rawPOSTData, 0, $length);
+ $strlen = strlen($string);
+ socket_write($socket, "\x12\x34" . chr(($strlen + 2) >> 8) . chr($strlen + 2) . chr($strlen >> 8) . chr($strlen) . $string);
+ $requestObject->rawPOSTData = substr($requestObject->rawPOSTData, $strlen);
+ } else
+ socket_write($socket, "\x12\x34\x0\x0");
+ #.endif
+ return 5;
+ case /* .AJP13_SEND_BODY_CHUNK */:
+ $requestObject->answerBody .= substr($data, 7, (ord($data[5]) << 8) + ord($data[6]));
+ return 5;
+ case /* .AJP13_END_RESPONSE */:
+ if($data[5] == "\x01") {
+ $this->freeSockets[$socketID] = $socket;
+ } else {
+ @socket_shutdown($socket);
+ socket_close($socket);
+ unset($this->sockets[$socketID]);
+ }
+ $retval = array($this->requestSockets[$socketID], $requestObject);
+ unset($this->requestSockets[$socketID], $this->requests[$socketID]);
+ return $retval;
+ case /* .AJP13_SEND_HEADERS */:
+ // Get HTTP status code
+ $requestObject->answerCode = (ord($data[5]) << 8) + ord($data[6]);
+
+ // Read headers
+ $pos = 12 + (ord($data[7]) << 8) + ord($data[8]);
+ $totalLength = $contentLength + 4;
+ while($pos < $totalLength) {
+ if($data[$pos] == "\xa0") {
+ $valueLength = (ord($data[$pos + 2]) << 8) + ord($data[$pos + 3]);
+ $value = substr($data, $pos + 4, $valueLength);
+ switch($data[$pos + 1]) {
+ case "\x01":
+ $requestObject->setHeader('Content-Type', $value);
+ break;
+ case "\x02":
+ $requestObject->setHeader('Content-Language', $value);
+ break;
+ case "\x03":
+ $requestObject->setHeader('Content-Length', $value);
+ break;
+ case "\x04":
+ $requestObject->setHeader('Date', $value);
+ break;
+ case "\x05":
+ $requestObject->setHeader('Last-Modified', $value);
+ break;
+ case "\x06":
+ $requestObject->setHeader('Location', $value);
+ break;
+ case "\x07":
+ $requestObject->setHeader('Set-Cookie', $value);
+ break;
+ case "\x08":
+ $requestObject->setHeader('Set-Cookie2', $value);
+ break;
+ case "\x09":
+ $requestObject->setHeader('Servlet-Engine', $value);
+ break;
+ case "\x0a":
+ $requestObject->setHeader('Status', $value);
+ break;
+ case "\x0b":
+ $requestObject->setHeader('WWW-Authenticate', $value);
+ break;
+ }
+
+ $pos += $valueLength + 5;
+ } else {
+ $headerLength = (ord($data[$pos]) << 8) + ord($data[$pos + 1]);
+ $headerName = substr($data, $pos + 2, $headerLength);
+ $pos += $headerLength + 3;
+ $valueLength = (ord($data[$pos]) << 8) + ord($data[$pos + 1]);
+ $value = substr($data, $pos + 2, $valueLength);
+ $requestObject->setHeader($headerName, $value);
+ $pos += $valueLength + 3;
+ }
+ }
+ return 5;
+ }
+ }
+ }
?>
View
534 sys/FastCGI.class.php
@@ -1,268 +1,268 @@
-<?php
-
- /****************************************************************/
- /* Pancake */
- /* FastCGI.class.php */
- /* 2012 - 2013 Yussuf Khalil */
- /* License: http://pancakehttp.net/license/ */
- /****************************************************************/
-
- #.if 0
- namespace Pancake;
-
- if(PANCAKE !== true)
- exit;
- #.endif
-
- #.define 'FCGI_BEGIN_REQUEST' 1
- #.define 'FCGI_ABORT_REQUEST' 2
- #.define 'FCGI_END_REQUEST' 3
- #.define 'FCGI_PARAMS' 4
- #.define 'FCGI_STDIN' 5
- #.define 'FCGI_STDOUT' 6
- #.define 'FCGI_STDERR' 7
- #.define 'FCGI_DATA' 8
- #.define 'FCGI_GET_VALUES' 9
- #.define 'FCGI_GET_VALUES_RESULT' 10
- #.define 'FCGI_UNKNOWN_TYPE' 11
-
- #.define 'FCGI_RESPONDER' 1
- #.define 'FCGI_AUTHORIZER' 2
- #.define 'FCGI_FILTER' 3
- #.define 'FCGI_KEEP_CONN' 1
-
- #.define 'FCGI_REQUEST_COMPLETE' 0
- #.define 'FCGI_CANT_MPX_CONN' 1
- #.define 'FCGI_OVERLOADED' 2
- #.define 'FCGI_UNKNOWN_ROLE' 3
-
- #.define 'FCGI_APPEND_DATA' 1048576
-
- class FastCGI {
- private static $instances = array();
- private $mimeTypes = array();
- public $socket;
- private $requestID = 0;
- private $requests = array();
- private $requestSockets = array();
- private $lastHeaders = array();
- private $address = "";
- private $port = 0;
- private $type = "";
-
- public static function getInstance($name) {
- if(!isset(self::$instances[$name]))
- self::$instances[$name] = new self($name);
- return self::$instances[$name];
- }
-
- private function __construct($name) {
- $config = Config::get('fastcgi.' . $name);
-
- if(!$config)
- throw new \Exception('Undefined FastCGI configuration: ' . $name);
-
- $this->mimeTypes = $config['mimetypes'];
- $this->address = $config['address'];
- $this->port = $config['port'];
- $this->type = strtolower($config['type']);
-
- $this->connect();
- }
-
- private function connect() {
- $this->requestID = 0;
-
- switch($this->type) {
- case 'ipv6':
- $this->socket = socket_create(/* .constant 'AF_INET6' */, /* .constant 'SOCK_STREAM' */, /* .constant 'SOL_TCP' */);
- if(!socket_connect($this->socket, $this->address, $this->port)) {
- trigger_error('Unable to connect to FastCGI upstream server at ipv6:' . $this->address . ':' . $this->port, /* .constant 'E_USER_ERROR' */);
- return false;
- }
- break;
- case 'ipv4':
- $this->socket = socket_create(/* .constant 'AF_INET' */, /* .constant 'SOCK_STREAM' */, /* .constant 'SOL_TCP' */);
- if(!socket_connect($this->socket, $this->address, $this->port)) {
- trigger_error('Unable to connect to FastCGI upstream server at ipv4:' . $this->address . ':' . $this->port, /* .constant 'E_USER_ERROR' */);
- return false;
- }
- break;
- default:
- $this->socket = socket_create(/* .constant 'AF_UNIX' */, /* .constant 'SOCK_STREAM' */, 0);
- if(!socket_connect($this->socket, $this->address)) {
- trigger_error('Unable to connect to FastCGI upstream server at unix:' . $this->address, /* .constant 'E_USER_ERROR' */);
- return false;
- }
- }
-
- socket_set_option($this->socket, /* .constant 'SOL_SOCKET' */, /* .constant 'SO_KEEPALIVE' */, 1);
- return true;
- }
-
- public function getMimeTypes() {
- return $this->mimeTypes;
- }
-
- public function makeRequest(HTTPRequest $requestObject, $requestSocket) {
- /* FCGI_BEGIN_REQUEST */
- $requestIDInt = $this->requestID++;
- $requestID = ($requestIDInt < 256 ? "\0" . chr($requestIDInt) : chr($requestIDInt >> 8) . chr($requestIDInt));
-
- if(!$this->socket)
- $this->connect();
-
- /* VERSION . TYPE . REQUEST_ID (2) . CONTENT_LENGTH (2) . PADDING_LENGTH . RESERVED . ROLE (2) . FLAG . RESERVED (5) */
- if(!@socket_write($this->socket, "\1\1" . $requestID . "\0\x8\0\0\0\1\1\0\0\0\0\0")) {
- if(!$this->connect()) {
- $requestObject->invalidRequest(new invalidHTTPRequestException("Failed to connect to FastCGI upstream server", 502));
- return false;
- } else
- socket_write($this->socket, "\1\1" . $requestID . "\0\x8\0\0\0\1\1\0\0\0\0\0");
- }
-
- /* FCGI_PARAMS */
- $body = "\xf" . chr(strlen(/* .VHOST_DOCUMENT_ROOT */ . /* .REQUEST_FILE_PATH */)) . "SCRIPT_FILENAME" . /* .VHOST_DOCUMENT_ROOT */ . /* .REQUEST_FILE_PATH */;
- $body .= "\xc" . chr(strlen(/* .QUERY_STRING */)) . "QUERY_STRING" . /* .QUERY_STRING */;
- $body .= "\xe" . chr(strlen(/* .REQUEST_TYPE */)) . "REQUEST_METHOD" . /* .REQUEST_TYPE */;
- $body .= "\xb" . chr(strlen(/* .REQUEST_FILE_PATH */)) . "SCRIPT_NAME" . /* .REQUEST_FILE_PATH */;
- $body .= "\xf\x8SERVER_PROTOCOLHTTP/" . /* .PROTOCOL_VERSION */;
- $body .= "\x11\x7GATEWAY_INTERFACECGI/1.1";
- $body .= "\xb" . chr(strlen($requestObject->originalRequestURI)) . "REQUEST_URI" . $requestObject->originalRequestURI;
- $body .= "\xc" . chr(strlen(/* .REQUEST_URI */)) . "DOCUMENT_URI" . /* .REQUEST_URI */;
- $body .= "\xb" . chr(strlen(/* .REMOTE_IP */)) . "REMOTE_ADDR" . /* .REMOTE_IP */;
- $body .= "\xb" . chr(strlen(/* .VHOST */->listen[0])) . "SERVER_NAME" . /* .VHOST */->listen[0];
- $body .= "\xb" . chr(strlen(/* .LOCAL_PORT */)) . "SERVER_PORT" . /* .LOCAL_PORT */;
- $body .= /* .eval 'return "\xf" . chr(strlen("Pancake/" . \Pancake\VERSION)) . "SERVER_SOFTWAREPancake/" . \Pancake\VERSION;' */;
- $body .= "\xb" . chr(strlen(/* .LOCAL_IP */)) . "SERVER_ADDR" . /* .LOCAL_IP */;
- if($requestObject->pathInfo) {
- $body .= "\x9" . chr(strlen($requestObject->pathInfo)) . "PATH_INFO" . $requestObject->pathInfo;
- $body .= "\xf" . chr(strlen($requestObject->vHost->documentRoot . $requestObject->pathInfo)) . "PATH_TRANSLATED" . $requestObject->vHost->documentRoot . $requestObject->pathInfo;
- }
-
- if(/* .RAW_POST_DATA */) {
- $body .= "\xc" . chr(strlen(/* .GET_REQUEST_HEADER '"content-type"' */)) . "CONTENT_TYPE" . /* .GET_REQUEST_HEADER '"content-type"' */;
- $body .= "\xe" . chr(strlen(/* .GET_REQUEST_HEADER '"content-length"' */)) . "CONTENT_LENGTH" . /* .GET_REQUEST_HEADER '"content-length"' */;
- }
-
- // HTTP header data
- foreach($requestObject->requestHeaders as $headerName => $headerValue) {
- $headerName = 'HTTP_' . str_replace('-', '_', strtoupper($headerName));
- if($headerName == 'HTTP_CONNECTION'
- || $headerName == 'HTTP_CONTENT_TYPE'
- || $headerName == 'HTTP_CONTENT_LENGTH'
- || $headerName == 'HTTP_AUTHORIZATION')
- continue;
- $strlenName = strlen($headerName);
- $strlenValue = strlen($headerValue);
- if($strlenName < 128 && $strlenValue < 128)
- $body .= chr($strlenName) . chr($strlenValue) . $headerName . $headerValue;
- else
- $body .= chr(($strlenName >> 24) | 128) . chr($strlenName >> 16) . chr($strlenName >> 8) . chr($strlenName) . chr(($strlenValue >> 24) | 128) . chr($strlenValue >> 16) . chr($strlenValue >> 8) . chr($strlenValue) . $headerName . $headerValue;
- }
-
- $strlen = strlen($body);
- $strlen = ($strlen < 256 ? ("\0" . chr($strlen)) : (chr($strlen >> 8) . chr($strlen)));
- socket_write($this->socket, "\1\4" . $requestID . $strlen . "\0\0" . $body);
-
- /* Empty FCGI_PARAMS */
- socket_write($this->socket, "\1\4" . $requestID . "\0\0\0\0");
-
- if(/* .RAW_POST_DATA */) {
- #.ifdef 'USE_IOCACHE'
- global $ioCache;
- $rawPostData = str_split($ioCache->getBytes(/* .RAW_POST_DATA */, -1), 65535);
- $ioCache->deallocateBuffer(/* .RAW_POST_DATA */);
- #.else
- $rawPostData = str_split(/* .RAW_POST_DATA */, 65535);
- #.endif
-
- foreach($rawPostData as $recordData) {
- /* FCGI_STDIN */
- $strlen = strlen($recordData);
- $contentLength = ($strlen < 256 ? ("\0" . chr($strlen)) : (chr($strlen >> 8) . chr($strlen)));
- socket_write($this->socket, "\1\5" . $requestID . $contentLength . "\0\0" . $recordData);
- }
-
- /* Empty FCGI_STDIN */
- socket_write($this->socket, "\1\5" . $requestID . "\0\0\0\0");
- }
-
- $requestObject->fCGISocket = (int) $this->socket;
-
- $this->requests[$requestIDInt] = $requestObject;
- $this->requestSockets[$requestIDInt] = $requestSocket;
-
- if($this->requestID == 65536)
- $this->requestID = 0;
- }
-
- public function upstreamRecord($data, $socketID) {
- if($data === "" || $data === false) {
- /* Upstream server closed connection */
- foreach($this->requests as $requestID => $requestObject) {
- if($requestObject->fCGISocket != $socketID)
- continue;
-
- $requestObject->invalidRequest(new invalidHTTPRequestException("The FastCGI upstream server unexpectedly closed the network connection.", 502));
-
- $retval = array($this->requestSockets[$requestID], $requestObject, true);
- unset($this->requestSockets[$requestID], $this->requests[$requestID]);
- return $retval;
- }
-
- $this->connect();
- return 0;
- }
- if(strlen($data) < 8)
- return /* .constant 'FCGI_APPEND_DATA' */ | (8 - strlen($data));
-
- $contentLength = (ord($data[4]) << 8) + ord($data[5]);
- $requestID = (ord($data[2]) << 8) + ord($data[3]);
- $requestObject = $this->requests[$requestID];
- $paddingLength = ord($data[6]);
-
- if(strlen($data) < (8 + $contentLength + $paddingLength))
- return /* .constant 'FCGI_APPEND_DATA' */ | (8 + $contentLength + $paddingLength - strlen($data));
-
- $type = ord($data[1]);
-
- $data = substr($data, 8, $contentLength);
-
- switch($type) {
- case /* .constant 'FCGI_STDOUT' */:
- if(!$requestObject->headerDataCompleted) {
- if(strpos($data, "\r\n\r\n"))
- $requestObject->headerDataCompleted = true;
- $contentBody = explode("\r\n\r\n", $data, 2);
- foreach(explode("\r\n", $contentBody[0]) as $header) {
- list($headerName, $headerValue) = explode(":", $header, 2);
- if($headerName == 'Status') {
- /* .ANSWER_CODE */ = (int) $headerValue;
- continue;
- }
- $requestObject->setHeader(trim($headerName), trim($headerValue), false);
- }
-
- if(isset($contentBody[1]))
- /* .ANSWER_BODY */ .= $contentBody[1];
- return 8;
- }
-
- /* .ANSWER_BODY */ .= $data;
-
- return 8;
- case /* .constant 'FCGI_END_REQUEST' */:
- switch(ord($data[4])) {
- default:
- $requestObject->invalidRequest(new invalidHTTPRequestException('The upstream server is currently overloaded.', 502));
- // fallthrough
- case /* .constant 'FCGI_REQUEST_COMPLETE' */:
- $retval = array($this->requestSockets[$requestID], $requestObject);
- unset($this->requestSockets[$requestID], $this->requests[$requestID]);
- return $retval;
- }
- }
- }
- }
+<?php
+
+ /****************************************************************/
+ /* Pancake */
+ /* FastCGI.class.php */
+ /* 2012 - 2013 Yussuf Khalil */
+ /* License: http://pancakehttp.net/license/ */
+ /****************************************************************/
+
+ #.if 0
+ namespace Pancake;
+
+ if(PANCAKE !== true)
+ exit;
+ #.endif
+
+ #.define 'FCGI_BEGIN_REQUEST' 1
+ #.define 'FCGI_ABORT_REQUEST' 2
+ #.define 'FCGI_END_REQUEST' 3
+ #.define 'FCGI_PARAMS' 4
+ #.define 'FCGI_STDIN' 5
+ #.define 'FCGI_STDOUT' 6
+ #.define 'FCGI_STDERR' 7
+ #.define 'FCGI_DATA' 8
+ #.define 'FCGI_GET_VALUES' 9
+ #.define 'FCGI_GET_VALUES_RESULT' 10
+ #.define 'FCGI_UNKNOWN_TYPE' 11
+
+ #.define 'FCGI_RESPONDER' 1
+ #.define 'FCGI_AUTHORIZER' 2
+ #.define 'FCGI_FILTER' 3
+ #.define 'FCGI_KEEP_CONN' 1
+
+ #.define 'FCGI_REQUEST_COMPLETE' 0
+ #.define 'FCGI_CANT_MPX_CONN' 1
+ #.define 'FCGI_OVERLOADED' 2
+ #.define 'FCGI_UNKNOWN_ROLE' 3
+
+ #.define 'FCGI_APPEND_DATA' 1048576
+
+ class FastCGI {
+ private static $instances = array();
+ private $mimeTypes = array();
+ public $socket;
+ private $requestID = 0;
+ private $requests = array();
+ private $requestSockets = array();
+ private $lastHeaders = array();
+ private $address = "";
+ private $port = 0;
+ private $type = "";
+
+ public static function getInstance($name) {
+ if(!isset(self::$instances[$name]))
+ self::$instances[$name] = new self($name);
+ return self::$instances[$name];
+ }
+
+ private function __construct($name) {
+ $config = Config::get('fastcgi.' . $name);
+
+ if(!$config)
+ throw new \Exception('Undefined FastCGI configuration: ' . $name);
+
+ $this->mimeTypes = $config['mimetypes'];
+ $this->address = $config['address'];
+ $this->port = $config['port'];
+ $this->type = strtolower($config['type']);
+
+ $this->connect();
+ }
+
+ private function connect() {
+ $this->requestID = 0;
+
+ switch($this->type) {
+ case 'ipv6':
+ $this->socket = socket_create(/* .constant 'AF_INET6' */, /* .constant 'SOCK_STREAM' */, /* .constant 'SOL_TCP' */);
+ if(!socket_connect($this->socket, $this->address, $this->port)) {
+ trigger_error('Unable to connect to FastCGI upstream server at ipv6:' . $this->address . ':' . $this->port, /* .constant 'E_USER_ERROR' */);
+ return false;
+ }
+ break;
+ case 'ipv4':
+ $this->socket = socket_create(/* .constant 'AF_INET' */, /* .constant 'SOCK_STREAM' */, /* .constant 'SOL_TCP' */);
+ if(!socket_connect($this->socket, $this->address, $this->port)) {
+ trigger_error('Unable to connect to FastCGI upstream server at ipv4:' . $this->address . ':' . $this->port, /* .constant 'E_USER_ERROR' */);
+ return false;
+ }
+ break;
+ default:
+ $this->socket = socket_create(/* .constant 'AF_UNIX' */, /* .constant 'SOCK_STREAM' */, 0);
+ if(!socket_connect($this->socket, $this->address)) {
+ trigger_error('Unable to connect to FastCGI upstream server at unix:' . $this->address, /* .constant 'E_USER_ERROR' */);
+ return false;
+ }
+ }
+
+ socket_set_option($this->socket, /* .constant 'SOL_SOCKET' */, /* .constant 'SO_KEEPALIVE' */, 1);
+ return true;
+ }
+
+ public function getMimeTypes() {
+ return $this->mimeTypes;
+ }
+
+ public function makeRequest(HTTPRequest $requestObject, $requestSocket) {
+ /* FCGI_BEGIN_REQUEST */
+ $requestIDInt = $this->requestID++;
+ $requestID = ($requestIDInt < 256 ? "\0" . chr($requestIDInt) : chr($requestIDInt >> 8) . chr($requestIDInt));
+
+ if(!$this->socket)
+ $this->connect();
+
+ /* VERSION . TYPE . REQUEST_ID (2) . CONTENT_LENGTH (2) . PADDING_LENGTH . RESERVED . ROLE (2) . FLAG . RESERVED (5) */
+ if(!@socket_write($this->socket, "\1\1" . $requestID . "\0\x8\0\0\0\1\1\0\0\0\0\0")) {
+ if(!$this->connect()) {
+ $requestObject->invalidRequest(new invalidHTTPRequestException("Failed to connect to FastCGI upstream server", 502));
+ return false;
+ } else
+ socket_write($this->socket, "\1\1" . $requestID . "\0\x8\0\0\0\1\1\0\0\0\0\0");
+ }
+
+ /* FCGI_PARAMS */
+ $body = "\xf" . chr(strlen(/* .VHOST_DOCUMENT_ROOT */ . /* .REQUEST_FILE_PATH */)) . "SCRIPT_FILENAME" . /* .VHOST_DOCUMENT_ROOT */ . /* .REQUEST_FILE_PATH */;
+ $body .= "\xc" . chr(strlen(/* .QUERY_STRING */)) . "QUERY_STRING" . /* .QUERY_STRING */;
+ $body .= "\xe" . chr(strlen(/* .REQUEST_TYPE */)) . "REQUEST_METHOD" . /* .REQUEST_TYPE */;
+ $body .= "\xb" . chr(strlen(/* .REQUEST_FILE_PATH */)) . "SCRIPT_NAME" . /* .REQUEST_FILE_PATH */;
+ $body .= "\xf\x8SERVER_PROTOCOLHTTP/" . /* .PROTOCOL_VERSION */;
+ $body .= "\x11\x7GATEWAY_INTERFACECGI/1.1";
+ $body .= "\xb" . chr(strlen($requestObject->originalRequestURI)) . "REQUEST_URI" . $requestObject->originalRequestURI;
+ $body .= "\xc" . chr(strlen(/* .REQUEST_URI */)) . "DOCUMENT_URI" . /* .REQUEST_URI */;
+ $body .= "\xb" . chr(strlen(/* .REMOTE_IP */)) . "REMOTE_ADDR" . /* .REMOTE_IP */;
+ $body .= "\xb" . chr(strlen(/* .VHOST */->listen[0])) . "SERVER_NAME" . /* .VHOST */->listen[0];
+ $body .= "\xb" . chr(strlen(/* .LOCAL_PORT */)) . "SERVER_PORT" . /* .LOCAL_PORT */;
+ $body .= /* .eval 'return "\xf" . chr(strlen("Pancake/" . \Pancake\VERSION)) . "SERVER_SOFTWAREPancake/" . \Pancake\VERSION;' */;
+ $body .= "\xb" . chr(strlen(/* .LOCAL_IP */)) . "SERVER_ADDR" . /* .LOCAL_IP */;
+ if($requestObject->pathInfo) {
+ $body .= "\x9" . chr(strlen($requestObject->pathInfo)) . "PATH_INFO" . $requestObject->pathInfo;
+ $body .= "\xf" . chr(strlen($requestObject->vHost->documentRoot . $requestObject->pathInfo)) . "PATH_TRANSLATED" . $requestObject->vHost->documentRoot . $requestObject->pathInfo;
+ }
+
+ if(/* .RAW_POST_DATA */) {
+ $body .= "\xc" . chr(strlen(/* .GET_REQUEST_HEADER '"content-type"' */)) . "CONTENT_TYPE" . /* .GET_REQUEST_HEADER '"content-type"' */;
+ $body .= "\xe" . chr(strlen(/* .GET_REQUEST_HEADER '"content-length"' */)) . "CONTENT_LENGTH" . /* .GET_REQUEST_HEADER '"content-length"' */;
+ }
+
+ // HTTP header data
+ foreach($requestObject->requestHeaders as $headerName => $headerValue) {
+ $headerName = 'HTTP_' . str_replace('-', '_', strtoupper($headerName));
+ if($headerName == 'HTTP_CONNECTION'
+ || $headerName == 'HTTP_CONTENT_TYPE'
+ || $headerName == 'HTTP_CONTENT_LENGTH'
+ || $headerName == 'HTTP_AUTHORIZATION')
+ continue;
+ $strlenName = strlen($headerName);
+ $strlenValue = strlen($headerValue);
+ if($strlenName < 128 && $strlenValue < 128)
+ $body .= chr($strlenName) . chr($strlenValue) . $headerName . $headerValue;
+ else
+ $body .= chr(($strlenName >> 24) | 128) . chr($strlenName >> 16) . chr($strlenName >> 8) . chr($strlenName) . chr(($strlenValue >> 24) | 128) . chr($strlenValue >> 16) . chr($strlenValue >> 8) . chr($strlenValue) . $headerName . $headerValue;
+ }
+
+ $strlen = strlen($body);
+ $strlen = ($strlen < 256 ? ("\0" . chr($strlen)) : (chr($strlen >> 8) . chr($strlen)));
+ socket_write($this->socket, "\1\4" . $requestID . $strlen . "\0\0" . $body);
+
+ /* Empty FCGI_PARAMS */
+ socket_write($this->socket, "\1\4" . $requestID . "\0\0\0\0");
+
+ if(/* .RAW_POST_DATA */) {
+ #.ifdef 'USE_IOCACHE'
+ global $ioCache;
+ $rawPostData = str_split($ioCache->getBytes(/* .RAW_POST_DATA */, -1), 65535);
+ $ioCache->deallocateBuffer(/* .RAW_POST_DATA */);
+ #.else
+ $rawPostData = str_split(/* .RAW_POST_DATA */, 65535);
+ #.endif
+
+ foreach($rawPostData as $recordData) {
+ /* FCGI_STDIN */
+ $strlen = strlen($recordData);
+ $contentLength = ($strlen < 256 ? ("\0" . chr($strlen)) : (chr($strlen >> 8) . chr($strlen)));
+ socket_write($this->socket, "\1\5" . $requestID . $contentLength . "\0\0" . $recordData);
+ }
+
+ /* Empty FCGI_STDIN */
+ socket_write($this->socket, "\1\5" . $requestID . "\0\0\0\0");
+ }
+
+ $requestObject->fCGISocket = (int) $this->socket;
+
+ $this->requests[$requestIDInt] = $requestObject;
+ $this->requestSockets[$requestIDInt] = $requestSocket;
+
+ if($this->requestID == 65536)
+ $this->requestID = 0;
+ }
+
+ public function upstreamRecord($data, $socketID) {
+ if($data === "" || $data === false) {
+ /* Upstream server closed connection */
+ foreach($this->requests as $requestID => $requestObject) {
+ if($requestObject->fCGISocket != $socketID)
+ continue;
+
+ $requestObject->invalidRequest(new invalidHTTPRequestException("The FastCGI upstream server unexpectedly closed the network connection.", 502));
+
+ $retval = array($this->requestSockets[$requestID], $requestObject, true);
+ unset($this->requestSockets[$requestID], $this->requests[$requestID]);
+ return $retval;
+ }
+
+ $this->connect();
+ return 0;
+ }
+ if(strlen($data) < 8)
+ return /* .constant 'FCGI_APPEND_DATA' */ | (8 - strlen($data));
+
+ $contentLength = (ord($data[4]) << 8) + ord($data[5]);
+ $requestID = (ord($data[2]) << 8) + ord($data[3]);
+ $requestObject = $this->requests[$requestID];
+ $paddingLength = ord($data[6]);
+
+ if(strlen($data) < (8 + $contentLength + $paddingLength))
+ return /* .constant 'FCGI_APPEND_DATA' */ | (8 + $contentLength + $paddingLength - strlen($data));
+
+ $type = ord($data[1]);
+
+ $data = substr($data, 8, $contentLength);
+
+ switch($type) {
+ case /* .constant 'FCGI_STDOUT' */:
+ if(!$requestObject->headerDataCompleted) {
+ if(strpos($data, "\r\n\r\n"))
+ $requestObject->headerDataCompleted = true;
+ $contentBody = explode("\r\n\r\n", $data, 2);
+ foreach(explode("\r\n", $contentBody[0]) as $header) {
+ list($headerName, $headerValue) = explode(":", $header, 2);
+ if($headerName == 'Status') {