You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.2 KiB

  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP version 4.0 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available at through the world-wide-web at |
  10. | http://www.php.net/license/2_01.txt. |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Rasmus Lerdorf <rasmus@php.net> |
  16. | (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
  17. | PHP 4.0 patches by: |
  18. | Zeev Suraski <zeev@zend.com> |
  19. | Stig Bakken <ssb@fast.no> |
  20. +----------------------------------------------------------------------+
  21. */
  22. /* $Id$ */
  23. #define NO_REGEX_EXTRA_H
  24. #ifdef WIN32
  25. #include <winsock2.h>
  26. #include <stddef.h>
  27. #endif
  28. #include "php.h"
  29. #include "httpd.h"
  30. #include "http_config.h"
  31. #if MODULE_MAGIC_NUMBER > 19980712
  32. # include "ap_compat.h"
  33. #else
  34. # if MODULE_MAGIC_NUMBER > 19980324
  35. # include "compat.h"
  36. # endif
  37. #endif
  38. #include "http_core.h"
  39. #include "http_main.h"
  40. #include "http_protocol.h"
  41. #include "http_request.h"
  42. #include "http_log.h"
  43. #include "zend.h"
  44. #include "php_ini.h"
  45. #include "php_globals.h"
  46. #include "SAPI.h"
  47. #include "main.h"
  48. #include "zend_compile.h"
  49. #include "zend_execute.h"
  50. #include "zend_highlight.h"
  51. #include "zend_indent.h"
  52. #include "ext/standard/php_standard.h"
  53. #include "util_script.h"
  54. #include "php_version.h"
  55. /*#include "mod_php4.h"*/
  56. int apache_php_module_main(request_rec *r, int fd, int display_source_mode CLS_DC ELS_DC PLS_DC SLS_DC)
  57. {
  58. zend_file_handle file_handle;
  59. if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) {
  60. return FAILURE;
  61. }
  62. #ifdef PHP_WIN32
  63. /* sending a file handle to another dll is not working
  64. // so let zend open it.
  65. */
  66. file_handle.type = ZEND_HANDLE_FILENAME;
  67. file_handle.handle.fd = 0;
  68. #else
  69. file_handle.type = ZEND_HANDLE_FD;
  70. file_handle.handle.fd = fd;
  71. #endif
  72. file_handle.filename = SG(request_info).path_translated;
  73. file_handle.free_filename = 0;
  74. if (display_source_mode) {
  75. zend_syntax_highlighter_ini syntax_highlighter_ini;
  76. if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) {
  77. php_get_highlight_struct(&syntax_highlighter_ini);
  78. zend_highlight(&syntax_highlighter_ini);
  79. return OK;
  80. } else {
  81. return NOT_FOUND;
  82. }
  83. } else {
  84. (void) php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
  85. }
  86. php_header(); /* Make sure headers have been sent */
  87. php_end_ob_buffering(1);
  88. return (OK);
  89. }
  90. /*
  91. * Local variables:
  92. * tab-width: 4
  93. * c-basic-offset: 4
  94. * End:
  95. */