From 9654c9d9e738d04e83dcb0ef43cbb7546e51e7e5 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Fri, 20 May 2011 22:44:35 +1000 Subject: experimental SCP writing (for using Tinyboard over multiple servers) --- inc/functions.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 65705766..ec6166ef 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -212,9 +212,23 @@ } function file_write($path, $data) { + global $config; + if(preg_match('/^scp:\/\/(.+)$/', $path, $m)) { + // Experimental: secure copy... + $file = tempnam($config['tmp'], 'tinyboard-scp'); + // Write to temp file + file_write($file, $data); + // Call `scp` (yes, this is horrible) + $command = 'scp ' . escapeshellarg($file) . ' ' . escapeshellarg($m[1]); + system($command); + // Delete temporary file + unlink($file); + exit; + } + if(!$fp = fopen($path, 'c')) error('Unable to open file for writing: ' . $path); - + // File locking if(!flock($fp, LOCK_EX)) { error('Unable to lock file: ' . $path); -- cgit v1.3