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.

101 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. #include "php.h"
  25. #include "httpd.h"
  26. #include "http_config.h"
  27. #if MODULE_MAGIC_NUMBER > 19980712
  28. # include "ap_compat.h"
  29. #else
  30. # if MODULE_MAGIC_NUMBER > 19980324
  31. # include "compat.h"
  32. # endif
  33. #endif
  34. #include "http_core.h"
  35. #include "http_main.h"
  36. #include "http_protocol.h"
  37. #include "http_request.h"
  38. #include "http_log.h"
  39. #include "zend.h"
  40. #include "php_ini.h"
  41. #include "php_globals.h"
  42. #include "SAPI.h"
  43. #include "main.h"
  44. #include "zend_compile.h"
  45. #include "zend_execute.h"
  46. #include "zend_highlight.h"
  47. #include "zend_indent.h"
  48. #include "ext/standard/php_standard.h"
  49. #include "util_script.h"
  50. #include "php_version.h"
  51. /*#include "mod_php4.h"*/
  52. PHPAPI int apache_php_module_main(request_rec *r, int fd, int display_source_mode SLS_DC)
  53. {
  54. zend_file_handle file_handle;
  55. #ifdef ZTS
  56. zend_compiler_globals cg;
  57. zend_executor_globals eg;
  58. php_core_globals pcg;
  59. zend_compiler_globals *compiler_globals=&cg;
  60. zend_executor_globals *executor_globals=&eg;
  61. php_core_globals *core_globals=&pcg;
  62. #endif
  63. if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) {
  64. return FAILURE;
  65. }
  66. file_handle.type = ZEND_HANDLE_FD;
  67. file_handle.handle.fd = fd;
  68. file_handle.filename = SG(request_info).path_translated;
  69. file_handle.free_filename = 0;
  70. if (display_source_mode) {
  71. zend_syntax_highlighter_ini syntax_highlighter_ini;
  72. if (open_file_for_scanning(&file_handle CLS_CC)==SUCCESS) {
  73. php_get_highlight_struct(&syntax_highlighter_ini);
  74. zend_highlight(&syntax_highlighter_ini);
  75. return OK;
  76. } else {
  77. return NOT_FOUND;
  78. }
  79. } else {
  80. (void) php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
  81. }
  82. php_header(); /* Make sure headers have been sent */
  83. php_end_ob_buffering(1);
  84. return (OK);
  85. }
  86. /*
  87. * Local variables:
  88. * tab-width: 4
  89. * c-basic-offset: 4
  90. * End:
  91. */