summaryrefslogtreecommitdiffstats
path: root/library/Poolctrl/Functions.php
blob: 0b893908a1e3e20931aef4b1363d89dd1c601430 (plain) (blame)
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
<?php
/*
 * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
 * This program is free software distributed under the GPL version 2.
 * See http://gpl.openslx.org/
 *
 * If you have any feedback please consult http://feedback.openslx.org/ and
 * send your suggestions, praise, or complaints to feedback@openslx.org
 *
 * General information about OpenSLX can be found at http://openslx.org/
 */
function randomString($name_laenge = 16) {
	$zeichen = "abcedfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRTSUVWXYZ0123456789";
	$name_neu = "";

	mt_srand ((double) microtime() * 1000000);
	for ($i = 0; $i < $name_laenge; $i++ ) {
		$name_neu .= $zeichen{mt_rand (0,strlen($zeichen) - 1)};
	}
	return $name_neu;
}

function print_a(){
	$numargs = func_num_args();
	if($numargs>1){
		$out = '';
		ob_start();
		echo "<div style='background-color:#FFCC33;border:1px solid black;margin:3px;padding:5px;'>";
		for($a=0;$a<$numargs;$a++)
		print_a(func_get_arg($a));
		echo "</div>";
		$out .= ob_get_contents();
		ob_end_clean();
		echo $out;
	}else{
		echo "<pre style='background-color:#FFDF80;border:1px solid #000;margin:3px;padding:5px;'>";
		$a = func_get_arg(0);
		$a = (is_bool($a))?(($a)?'true':'false'):$a;
		print_r($a);
		echo "</pre>";
	}
}

function PostToHost($host, $path, $referer, $userAgent, $dataToSend) {
	$fp = @ fsockopen($host, 80);
	@ fputs($fp, "POST $path HTTP/1.1\r\n");
	@ fputs($fp, "Host: $host\r\n");
	@ fputs($fp, "User-Agent: $userAgent\r\n");
	@ fputs($fp, "Referer: $referer\r\n");
	@ fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
	@ fputs($fp, "Content-length: ". strlen($dataToSend) ."\r\n");
	@ fputs($fp, "Connection: close\r\n\r\n");
	@ fputs($fp, $dataToSend);
	$res = "";
	while(!@ feof($fp)) {
		$res .= @ fgets($fp, 128);
	}
	@ fclose($fp);

	$res = @ explode("\r\n\r\n",$res);
	$result['http-header'] = $res[0];
	$result['http-body'] = $res[1];
	return $result;
}