summaryrefslogtreecommitdiff
path: root/shell/bin/cat.php
blob: 8376ca082bc3f21847ac6fb7f0ec14941d1b015f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
class p_cat extends prog {
	public static function main($args, $env) {
		$me = array_shift($args);
		$raw = (isset($args[0])?($args[0]=='-r'):false);
		if ($raw) {
			array_shift($args);
		}
		if (count($args)==0) { $args = array('-'); }
		foreach ($args as $file) {
			if ( ($file=='-') || ($file=='/dev/stdin') ) {
				echo $_POST['stdin'];
			} else {
				if ($raw) {
					echo file_get_contents($file);
				} else {
					echo htmlentities(file_get_contents($file));
				}
			}
		}
	}
}