This file is indexed.

/usr/share/sbnc-php/classbuilder.php is in sbnc-php-dev 1.3.9-3.

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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php

include_once('sbnc.php');

function indentCode($lines, $tabs) {
	$lines_out = array();
	$lines_in = explode("\n", $lines);

	foreach ($lines_in as $line) {
		$lines_out[] = str_repeat("\t", $tabs) . $line;
	}

	return implode("\n", $lines_out);
}

class ClassBuilder {
	var $className, $methods, $customFunctionBody;

	function ClassBuilder($className) {
		$this->className = $className;
		$this->methods = array();
		$this->customFunctionBody = '';

		$this->addVariable('wrappedObj');
	}

	function loadClass() {
		eval($this->buildClass());
	}

	function addMethod($name, $parameterNames) {
		$this->methods[] = array( $name, $parameterNames );
	}

	function addVariable($variableName) {
		$this->variables[] = $variableName;
	}

	function setCustomFunctionBody($body) {
		$this->customFunctionBody = $body;
	}

	function buildClass() {
		$classBody = "class {$this->className} \{\n";

		foreach ($this->variables as $variable) {
			$classBody .= indentCode($this->buildVariable($variable), 1) . "\n";
		}

		$classBody .= indentCode($this->buildConstructor(), 1) . "\n";

		foreach ($this->methods as $method) {
			$classBody .= "\n" . indentCode($this->buildFunction($method[0], $method[1]), 1) . "\n";
		}

		$classBody .= "}\n";

		return $classBody;
	}

	function buildVariable($variableName) {
		$variableBody = "var \${$variableName};\n";

		return $variableBody;
	}

	function buildConstructor() {
		$constructorBody = "function {$this->className}(\$wrappedObj) {\n\t\$this->wrappedObj = \$wrappedObj;\n}";

		return $constructorBody;
	}

	function buildFunction($name, $parameters) {
		$functionBody = "function {$name}(";

		$firstParam = true;

		foreach ($parameters as $parameter) {
			if ($firstParam) {
				$firstParam = false;
			} else {
				$functionBody .= ", ";
			}

			$functionBody .= "\${$parameter}";
		}

		$functionBody .= ") {\n";
		$functionBody .= indentCode($this->buildFunctionBody($name, $parameters), 1) . "\n";
		$functionBody .= "}";

		return $functionBody;
	}

	function buildFunctionBody($name, $parameters) {
		$functionBody = "\$functionName = '{$name}';\n";
		$functionBody .= "\$parameters = array( ";

		$firstParameter = true;

		foreach ($parameters as $parameter) {
			if ($firstParameter) {
				$firstParameter = false;
			} else {
				$functionBody .= ", ";
			}

			$functionBody .= "\${$parameter}";
		}

		$functionBody .= " );\n\n";

		$functionBody .= $this->customFunctionBody;

		return $functionBody;
	}
}

function buildSbncClass($className, $sbncObject) {
	$result = $sbncObject->Call("commands");

	if (IsError($result)) {
		return false;
	}

	$commands = GetResult($result);

	$params_calls = array();

	foreach ($commands as $command) {
		array_push( $params_calls, array( 'params', array( $command ) ) );
	}

	$result = $sbncObject->Call("multicall", array( $params_calls ) );

	if (IsError($result)) {
		return false;
	}

	$builder = new ClassBuilder($className);

	$i = 0;

	foreach ($commands as $command) {
		if (IsError($result[$i])) {
			die(GetCode($result[$i]));
		}

		if ($command != 'global') {
			$builder->addMethod($command, $result[$i]);
		}

		$i++;
	}	

	$builder->setCustomFunctionBody("\$result = \$this->wrappedObj->Call(\$functionName, \$parameters);\n\nreturn \$result;");

	$builder->loadClass();

	return true;
}

?>