experimental SCP writing (for using Tinyboard over multiple servers)
This commit is contained in:
parent
65c5e91af2
commit
9654c9d9e7
@ -221,6 +221,9 @@
|
|||||||
// Display the aspect ratio in a post's file info
|
// Display the aspect ratio in a post's file info
|
||||||
$config['show_ratio'] = true;
|
$config['show_ratio'] = true;
|
||||||
|
|
||||||
|
// Directory where temporary files will be created. Not really used much yet except for some experimental stuff.
|
||||||
|
$config['tmp'] = '/tmp';
|
||||||
|
|
||||||
// The root directory, including the trailing slash, for Tinyboard.
|
// The root directory, including the trailing slash, for Tinyboard.
|
||||||
// examples: '/', 'http://boards.chan.org/', '/chan/'
|
// examples: '/', 'http://boards.chan.org/', '/chan/'
|
||||||
$config['root'] = (str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) == '/' ? '/' : str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) . '/');
|
$config['root'] = (str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) == '/' ? '/' : str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) . '/');
|
||||||
|
@ -212,6 +212,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function file_write($path, $data) {
|
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'))
|
if(!$fp = fopen($path, 'c'))
|
||||||
error('Unable to open file for writing: ' . $path);
|
error('Unable to open file for writing: ' . $path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user