get_httpd_privileges() function for CLI scripts

This commit is contained in:
Michael Save
2012-03-15 01:44:29 +11:00
parent 2482723ff2
commit 64c1f6821c
2 changed files with 72 additions and 32 deletions

View File

@@ -1,12 +1,5 @@
#!/usr/bin/php
<?php
require 'inc/functions.php';
require 'inc/display.php';
require 'inc/template.php';
require 'inc/database.php';
require 'inc/user.php';
require 'inc/mod.php';
require dirname(__FILE__) . '/inc/cli.php';
$mod = Array(
@@ -21,31 +14,7 @@
echo "== Tinyboard {$config['version']} ==\n";
if(!is_writable($config['file_script'])) {
echo "Dropping priviledges... (I can't operate as user; I need PHP's rights.)\n";
$filename = '.' . md5(rand()) . '.php';
echo "Copying rebuilder to web directory...\n";
copy(__FILE__, $filename);
chmod($filename, 0666);
if(preg_match('/^https?:\/\//', $config['root'])) {
$url = $config['root'] . $filename;
} else {
// assume localhost
$url = 'http://localhost' . $config['root'] . $filename;
}
echo "Downloading $url\n";
passthru('curl -s -N ' . escapeshellarg($url));
echo "\n".'Cleaning up afterwards...'."\n";
unlink($filename);
echo "Bye!\n";
exit;
get_httpd_privileges();
}
echo "Clearing template cache...\n";