sapi_apache.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_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@php.net> |
  20. +----------------------------------------------------------------------+
  21. */
  22. /* $Id$ */
  23. #include "php_apache_http.h"
  24. /* {{{ apache_php_module_main
  25. */
  26. int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
  27. {
  28. int retval = OK;
  29. zend_file_handle file_handle;
  30. if (php_request_startup(TSRMLS_C) == FAILURE) {
  31. return FAILURE;
  32. }
  33. /* sending a file handle to another dll is not working
  34. so let zend open it. */
  35. if (display_source_mode) {
  36. zend_syntax_highlighter_ini syntax_highlighter_ini;
  37. php_get_highlight_struct(&syntax_highlighter_ini);
  38. if (highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC) != SUCCESS) {
  39. retval = NOT_FOUND;
  40. }
  41. } else {
  42. file_handle.type = ZEND_HANDLE_FILENAME;
  43. file_handle.handle.fd = 0;
  44. file_handle.filename = SG(request_info).path_translated;
  45. file_handle.opened_path = NULL;
  46. file_handle.free_filename = 0;
  47. (void) php_execute_script(&file_handle TSRMLS_CC);
  48. }
  49. AP(in_request) = 0;
  50. zend_try {
  51. php_request_shutdown(NULL);
  52. } zend_end_try();
  53. return retval;
  54. }
  55. /* }}} */
  56. /*
  57. * Local variables:
  58. * tab-width: 4
  59. * c-basic-offset: 4
  60. * End:
  61. * vim600: sw=4 ts=4 fdm=marker
  62. * vim<600: sw=4 ts=4
  63. */