Skip to content

Instantly share code, notes, and snippets.

@cs278
Created December 16, 2008 00:59
Show Gist options
  • Save cs278/36202 to your computer and use it in GitHub Desktop.
Save cs278/36202 to your computer and use it in GitHub Desktop.
<?php
header('Content-type: text/plain');
foreach (array('index', 'mcp', 'ucp', 'config', 'adm/index') as $file)
{
if (!file_exists("./$file.php"))
{
die(sprintf('Sure this is in your phpBB directory? "%s" is missing', $file));
}
}
$test_file = './cache/phpbb_chmod_debug.test';
touch($test_file);
$code = array(
"php_uname()",
"function_exists('fileowner')",
"function_exists('filegroup')",
"function_exists('posix_getuid')",
"function_exists('posix_getgroups')",
"function_exists('posix_getpwuid')",
"function_exists('posix_getgrgid')",
);
if (function_exists('fileowner'))
{
$code = array_merge($code, array(
"fileowner('./common.php')",
"fileowner('$test_file')",
));
}
if (function_exists('filegroup'))
{
$code = array_merge($code, array(
"filegroup('./common.php')",
"filegroup('$test_file')",
));
}
if (function_exists('posix_getuid'))
{
$code = array_merge($code, array(
"posix_getuid()",
));
}
if (function_exists('posix_getgroups'))
{
$code = array_merge($code, array(
"posix_getgroups()",
));
}
if (function_exists('posix_getuid') && function_exists('posix_getpwuid'))
{
$code = array_merge($code, array(
"posix_getpwuid(posix_getuid())",
));
}
if (function_exists('posix_getgroups') && function_exists('posix_getgrgid'))
{
$code = array_merge($code, array(
"array_map('posix_getgrgid', posix_getgroups())",
));
}
foreach ($code as $line)
{
echo sprintf("`%1\$s` yeilds:\n%2\$s\n\n", $line, eval(sprintf('return var_export(%s, true);', $line)));
}
unlink($test_file);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment