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 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.0 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_0.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. #include "php.h"
  24. #include "httpd.h"
  25. #include "http_config.h"
  26. #if MODULE_MAGIC_NUMBER > 19980712
  27. # include "ap_compat.h"
  28. #else
  29. # if MODULE_MAGIC_NUMBER > 19980324
  30. # include "compat.h"
  31. # endif
  32. #endif
  33. #include "http_core.h"
  34. #include "http_main.h"
  35. #include "http_protocol.h"
  36. #include "http_request.h"
  37. #include "http_log.h"
  38. #include "zend.h"
  39. #include "php_ini.h"
  40. #include "php_globals.h"
  41. #include "SAPI.h"
  42. #include "main.h"
  43. #include "zend_compile.h"
  44. #include "zend_execute.h"
  45. #include "zend_highlight.h"
  46. #include "zend_indent.h"
  47. #include "ext/standard/php3_standard.h"
  48. #include "util_script.h"
  49. #include "php_version.h"
  50. /*#include "mod_php4.h"*/
  51. PHPAPI int apache_php_module_main(request_rec *r, int fd, int display_source_mode SLS_DC)
  52. {
  53. zend_file_handle file_handle;
  54. #ifdef ZTS
  55. zend_compiler_globals cg;
  56. zend_executor_globals eg;
  57. php_core_globals pcg;
  58. zend_compiler_globals *compiler_globals=&cg;
  59. zend_executor_globals *executor_globals=&eg;
  60. php_core_globals *core_globals=&pcg;
  61. #endif
  62. SLS_FETCH();
  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. fclose(file_handle.handle.fp);
  76. return OK;
  77. } else {
  78. return NOT_FOUND;
  79. }
  80. } else {
  81. (void) php_execute_script(&file_handle CLS_CC ELS_CC);
  82. }
  83. php3_header(); /* Make sure headers have been sent */
  84. php_end_ob_buffering(1);
  85. return (OK);
  86. }
  87. /*
  88. * Local variables:
  89. * tab-width: 4
  90. * c-basic-offset: 4
  91. * End:
  92. */