|
11 | 11 | fwrite(STDOUT, "\033[32;40;1;4mfoo\033[39;49;22;24m");
|
12 | 12 | fflush(STDOUT);
|
13 | 13 |
|
14 |
| -function execInBackground($cmd) |
15 |
| -{ |
16 |
| - if (substr(php_uname(), 0, 7) == "Windows") { |
17 |
| - pclose(popen("start /B " . $cmd, "r")); |
18 |
| - } else { |
19 |
| - exec($cmd . " > /dev/null &"); |
20 |
| - } |
21 |
| -} |
22 |
| -function GetProgCpuUsage($program) |
23 |
| -{ |
24 |
| - if (!$program) { |
25 |
| - return -1; |
26 |
| - } |
27 | 14 |
|
28 |
| - $c_pid = exec("ps aux | grep " . $program . " | grep -v grep | grep -v su | awk {'print $3'}"); |
29 |
| - return $c_pid; |
30 |
| -} |
31 | 15 |
|
32 |
| -function GetProgMemUsage($program) |
33 |
| -{ |
34 |
| - if (!$program) { |
35 |
| - return -1; |
36 |
| - } |
37 | 16 |
|
38 |
| - $c_pid = exec("ps aux | grep " . $program . " | grep -v grep | grep -v su | awk {'print $4'}"); |
39 |
| - return $c_pid; |
40 |
| -} |
41 | 17 |
|
42 |
| -// If you want to download files from a linux server with a filesize bigger than 2GB you can use the following |
43 |
| -function serveFile($file, $as) |
44 |
| -{ |
45 |
| - header('Expires: Mon, 1 Apr 1974 05:00:00 GMT'); |
46 |
| - header('Pragma: no-cache'); |
47 |
| - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
48 |
| - header('Content-Description: File Download'); |
49 |
| - header('Content-Type: application/octet-stream'); |
50 |
| - header('Content-Length: ' . trim(`stat -c%s "$file"`)); |
51 |
| - header('Content-Disposition: attachment; filename="' . $as . '"'); |
52 |
| - header('Content-Transfer-Encoding: binary'); |
53 |
| - //@readfile( $file ); |
54 |
| - |
55 |
| - flush(); |
56 |
| - $fp = popen("tail -c " . trim(`stat -c%s "$file"`) . " " . $file . ' 2>&1', "r"); |
57 |
| - while (!feof($fp)) { |
58 |
| - // send the current file part to the browser |
59 |
| - print fread($fp, 1024); |
60 |
| - // flush the content to the browser |
61 |
| - flush(); |
62 |
| - } |
63 |
| - fclose($fp); |
64 |
| -} |
0 commit comments