This file is indexed.

/usr/lib/nanoweb/modules/mod_gzip.php is in nanoweb 2.2.9-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php

/*

Nanoweb Gzip Transfer Encoding Support Module
=============================================

Copyright (C) 2002-2003 Vincent Negrier aka. sIX <six@aegis-corp.org>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


   # it now adds itself to the parser/filter chain
   # <mario@erphesfurt·de>

*/

class mod_gzip extends pfilter {

	function mod_gzip() {

		$this->modtype = "core_after_pfilters";
		$this->modname = "gzip content encoding support";

	}


	function init() {

		register_filter("gzip", $this, NW_PFILTER_ALL);

	}


	function main() {

		if ((access_query("gzipenable", 0) && $GLOBALS["gz_av"])) {

			global $lf;

			$this->pp = $lf;
			$this->content_length = $this->pp->content_length;
			$lf=$this;

		}

	}


	function filter_func(&$lf, $args) {

		global $htreq_headers, $out_add_headers, $first_chunk, $chunky;

		if ($first_chunk) { 

			$this->gz_method = false;
			foreach (array("deflate", "gzip", "compress") as $m) {
				if (strpos($htreq_headers["ACCEPT-ENCODING"], $m) !== false) {
					$this->gz_method = $m;
					break;
				}
			}

			if (!($this->gz_level=access_query("gziplevel", 0))) {
				$this->gz_level=3;
			}

			$this->engaged = $this->gz_method && empty($out_add_headers["Content-Encoding"]);
			$this->engaged = $this->engaged && ( !($chunky || (nw_use_chunked_encoding()==true)) || (access_query("gzipenable",0)>=2) );

		}

		if ($this->engaged) {

			switch ($this->gz_method) {
				case "deflate":
					$gz_content=gzdeflate($lf, $this->gz_level);
					break;
				case "compress":
					$gz_content=gzcompress($lf, $this->gz_level);
					break;
				case "gzip":
					$gz_content=gzencode($lf, $this->gz_level); //(..., FORCE_DEFLATE) ??
				default:
			}

#techo("compressing " . strlen($lf) . " bytes using " . $this->gz_method . " level=".$this->gz_level);

			if (!$chunky || isset($this->pp->content_length)) {

				if (!$maxratio=(access_query("gzipmaxratio", 0)/100)) $maxratio=0.90;

				if (!(strlen($gz_content)<(strlen($lf)*$maxratio))) {

					return(0);

				}

				$this->content_length = strlen($gz_content);
			}

			$lf=$gz_content;

			$out_add_headers["Content-Encoding"]=$this->gz_method;

		}
		else {

			$this->content_length = $this->pp->content_length;

		}
		
	}

}

?>