Project

General

Profile

« Previous | Next » 

Revision d17af2a5

Added by Jim Pingle over 9 years ago

A couple more refinements for pfSsh.php while I'm here.

View differences:

src/usr/local/sbin/pfSsh.php
85 85

  
86 86
	Example commands:
87 87

  
88
	startrecording <recordingfilename>
89
	stoprecording <recordingfilename>
88
	record <recordingfilename>
89
	stoprecording
90 90
	showrecordings
91 91

  
92 92
	parse_config(true);  # reloads the \$config array
......
166 166
	$playback_files = array();
167 167
	$files = scandir("/etc/phpshellsessions/");
168 168
	foreach ($files as $file) {
169
		if ($file <> "." and $file <> "..") {
169
		if ($file <> "." && $file <> "..") {
170 170
			$playback_files[] = $file;
171 171
		}
172 172
	}
......
196 196
if ($argv[1]=="playback" or $argv[1]=="run") {
197 197
	if (empty($argv[2]) || !file_exists("/etc/phpshellsessions/" . basename($argv[2]))) {
198 198
		echo "Error: Invalid playback file specified.\n\n";
199
		echo "Valid playback files are:\n";
200
		foreach (get_playback_files() as $pbf) {
201
			echo "{$pbf} ";
202
		}
203
		echo "\n\n";
199
		show_playback_files();
204 200
		exit(-1);
205 201
	}
206 202
	playback_file(basename($argv[2]));
......
212 208
$tccommands[] = "quit";
213 209
$tccommands[] = "?";
214 210
$tccommands[] = "exec";
215
$tccommands[] = "startrecording";
216 211
$tccommands[] = "stoprecording";
217 212
$tccommands[] = "showrecordings";
218 213
$tccommands[] = "record";
......
275 270
	if ($first_command == "record") {
276 271
		if (!$command_split[1]) {
277 272
			echo "usage: record playbackname\n";
273
			echo "\tplaybackname will be created in /etc/phpshellsessions.\n";
278 274
			$command = "";
279 275
		} else {
280 276
			/* time to record */
281 277
			conf_mount_rw();
282 278
			safe_mkdir("/etc/phpshellsessions");
283
			$recording_fd = fopen("/etc/phpshellsessions/{$command_split[1]}","w");
279
			$recording_fn = basename($command_split[1]);
280
			$recording_fd = fopen("/etc/phpshellsessions/{$recording_fn}","w");
284 281
			if (!$recording_fd) {
285 282
				echo "Could not start recording session.\n";
286 283
				$command = "";
287 284
			} else {
288 285
				$recording = true;
289
				echo "Recording of {$command_split[1]} started.\n";
286
				echo "Recording of {$recording_fn} started.\n";
290 287
				$command = "";
291 288
			}
292 289
		}
......
295 292
}
296 293

  
297 294
function show_recordings() {
298
	conf_mount_rw();
299
	safe_mkdir("/etc/phpshellsessions");
300
	if ($recording) {
301
		conf_mount_ro();
302
	}
303 295
	echo "==> Sessions available for playback are:\n";
304
	system("cd /etc/phpshellsessions && ls /etc/phpshellsessions");
296
	$playback_files = get_playback_files();
297
	foreach (get_playback_files() as $pbf) {
298
		echo "{$pbf} ";
299
	}
300
	echo "\n\n";
305 301
	echo "==> end of list.\n";
306 302
}
307 303

  

Also available in: Unified diff