Instantly share code, notes, and snippets.
Created
May 18, 2016 22:33
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save 3D-I/c0c18059dd0e8402243876e4bf09d381 to your computer and use it in GitHub Desktop.
Right Cookie for phpBB all versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('IN_PHPBB', true); | |
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; | |
$phpEx = substr(strrchr(__FILE__, '.'), 1); | |
include($phpbb_root_path . 'common.' . $phpEx); | |
// Start session management | |
$user->session_begin(); | |
$auth->acl($user->data); | |
/* Vars */ | |
$db_vers = $config['version']; | |
$version = PHPBB_VERSION; | |
$php_version = PHP_VERSION; | |
$styles_path = ($phpbb_root_path . 'styles'); | |
$files = glob('styles/*/style.cfg'); | |
$default_style = ((int) $config['default_style']); | |
$langs_path = ($phpbb_root_path . 'language'); | |
/* We backport the original function phpbb_version_compare just in case is not present*/ | |
$olympus_old = '3.0.10-RC1'; | |
$old_olympus = ((version_compare(PHPBB_VERSION, $olympus_old, "<")) ? true : false); | |
if ($old_olympus) | |
{ | |
function phpbb_version_compare($version1, $version2, $operator = null) | |
{ | |
$version1 = strtolower($version1); | |
$version2 = strtolower($version2); | |
if (is_null($operator)) | |
{ | |
return version_compare($version1, $version2); | |
} | |
else | |
{ | |
return version_compare($version1, $version2, $operator); | |
} | |
} | |
} | |
/* Ok, we can finally use the original function phpbb_version_compare from now on */ | |
$rhea = (phpbb_version_compare($db_vers, '3.2.0@dev', ">=")) ? true : false; | |
$ascraeus = ((phpbb_version_compare($db_vers, '3.1.0@dev', ">")) && (phpbb_version_compare($db_vers, '3.2.0@dev', '<'))) ? true : false; | |
$olympus = ((phpbb_version_compare(PHPBB_VERSION, '3.1.0@dev', "<")) && (phpbb_version_compare($db_vers, '3.1.0@dev', "<")) ? true : false); | |
/* If ANONYMOUS = login box */ | |
if ((int) $user->data['user_id'] == ANONYMOUS) | |
{ | |
if ($rhea || (!$olympus)) | |
{ | |
login_box($request->variable('redirect', "right_cookie.$phpEx")); // for 3.2 | |
} | |
else if ($ascraeus || (!$olympus)) | |
{ | |
login_box(request_var('redirect', "right_cookie.$phpEx")); // for 3.0 and 3.1 | |
} | |
else if ($olympus) | |
{ | |
login_box(request_var('redirect', "right_cookie.$phpEx")); // for 3.0 and 3.1 | |
} | |
} | |
if ((int) $user->data['user_type'] == USER_FOUNDER || $auth->acl_get('a_')) | |
{ | |
/* The party begins. If not correct versions tell them */ | |
if ($rhea || (!$olympus)) | |
{ | |
if ((phpbb_version_compare(PHPBB_VERSION, $db_vers, "<>")) || (version_compare(PHP_VERSION, '5.4.0', '<')) || (version_compare(PHP_VERSION, '7.1', '>'))) | |
{ | |
echo '<strong style="color:red">Versions mismatch:</strong><br />Your CONSTANTS file belongs to phpBB <font style="color:red">' . $version . '</font><br />Your DB says you are running phpBB <font style="color:red">' . $db_vers . '</font><br />Your PHP version says you are running PHP <font style="color:red">' . $php_version . '</font><br />'; | |
} | |
else if ((phpbb_version_compare(PHPBB_VERSION, $db_vers, "=")) && (version_compare(PHP_VERSION, '5.4.0', '>')) || (version_compare(PHP_VERSION, '7.1', '=<'))) | |
{ | |
echo '<strong style="color:green">Congratulations!</strong><br />Your CONSTANTS file belongs to phpBB <font style="color:green">' . $version . '</font><br />Your DB says you are running phpBB <font style="color:green">' . $db_vers . '</font><br />Your PHP version says you are running PHP <font style="color:green">' . $php_version . '</font><br />'; | |
} | |
} | |
else if ($ascraeus || (!$olympus)) | |
{ | |
if ((phpbb_version_compare(PHPBB_VERSION, $db_vers, "<>")) || (version_compare(PHP_VERSION, '5.3.3', '<')) || (version_compare(PHP_VERSION, '7.0.0', '>='))) | |
{ | |
echo '<strong style="color:red">Versions mismatch:</strong><br />Your CONSTANTS file belongs to phpBB <font style="color:red">' . $version . '</font><br />Your DB says you are running phpBB <font style="color:red">' . $db_vers . '</font><br />Your PHP version says you are running PHP <font style="color:red">' . $php_version . '</font><br />'; | |
} | |
else if ((phpbb_version_compare(PHPBB_VERSION, $db_vers, "=")) && (version_compare(PHP_VERSION, '5.3.3', '>')) && (version_compare(PHP_VERSION, '7.0.0', '<'))) | |
{ | |
echo '<strong style="color:green">Congratulations!</strong><br />Your CONSTANTS file belongs to phpBB <font style="color:green">' . $version . '</font><br />Your DB says you are running phpBB <font style="color:green">' . $db_vers . '</font><br />Your PHP version says you are running PHP <font style="color:green">' . $php_version . '</font><br />'; | |
} | |
} | |
else if ($olympus) | |
{ | |
if ((phpbb_version_compare(PHPBB_VERSION, $db_vers, "<>")) || (version_compare(PHP_VERSION, '4.3.3', '<')) || (version_compare(PHP_VERSION, '7.0.0', '>='))) | |
{ | |
echo '<strong style="color:red">Versions mismatch:</strong><br />Your CONSTANTS file belongs to phpBB <font style="color:red">' . $version . '</font><br />Your DB says you are running phpBB <font style="color:red">' . $db_vers . '</font><br />Your PHP version says you are running PHP <font style="color:red">' . $php_version . '</font><br />'; | |
} | |
else if ((phpbb_version_compare(PHPBB_VERSION, $db_vers, "=")) && (version_compare(PHP_VERSION, '4.3.3', '>')) && (version_compare(PHP_VERSION, '7.0.0', '<'))) | |
{ | |
echo '<strong style="color:green">Congratulations!</strong><br />Your CONSTANTS file belongs to phpBB <font style="color:green">' . $version . '</font><br />Your DB says you are running phpBB <font style="color:green">' . $db_vers . '</font><br />Your PHP version says you are running PHP <font style="color:green">' . $php_version . '</font><br />'; | |
} | |
} | |
echo '<strong style="color:purple">The following stats are just for information purposes at the present time</strong><br />'; | |
if (file_exists($phpbb_root_path . 'config.' . $phpEx)) | |
{ | |
echo 'The file config.php <font style="color:green">exists</font>, size: ' . filesize($phpbb_root_path . 'config.' . $phpEx) . ' bytes<br />'; | |
} | |
else | |
{ | |
echo 'The file config.php <font style="color:red">does not exists!</font><br />'; | |
} | |
echo 'Available stream wrappers: <font style="color:green">' . implode(', ', stream_get_wrappers()) . '</font><br />'; | |
// The following PHP modules are required: | |
// json ----> for ascraeus and rhea | |
// getimagesize() function must be enabled ----> For all | |
if (@extension_loaded('json')) | |
{ | |
echo 'PHP module json: <font style="color:green">loaded</font><i> (Required only for Acraeus and Rhea)</i><br />'; | |
} | |
else if ((@!extension_loaded('json')) || ($olympus)) | |
{ | |
echo 'PHP module json: <font style="color:red">not loaded</font>. (Required only for Acraeus and Rhea)<br />'; | |
} | |
else if ((@!extension_loaded('json')) || (($ascraeus) || ($rhea) || (!$olympus))) | |
{ | |
echo 'PHP module json: <font style="color:red">not loaded</font><br />'; | |
} | |
else | |
{ | |
echo 'PHP module json: <font style="color:red">Critical Error while finding the PHP module json</font><br />'; | |
} | |
if (@function_exists('getimagesize')) | |
{ | |
echo 'PHP function getimagesize: <font style="color:green">enabled.</font><br />'; | |
} | |
else if (@!function_exists('getimagesize')) | |
{ | |
echo 'PHP function getimagesize <font style="color:red">doesn\'t exists</font><br />'; | |
} | |
else | |
{ | |
echo 'PHP function getimagesize: <font style="color:red">Critical Error while finding the PHP function getimagesize</font><br />'; | |
} | |
/* checking url_fopen in php.ini */ | |
if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on') | |
{ | |
echo 'PHP module allow_url_fopen: <font style="color:green">loaded.</font><br />'; | |
} | |
else if (@!ini_get('allow_url_fopen') == '1' || strtolower(@!ini_get('allow_url_fopen')) == 'on') | |
{ | |
echo 'PHP module allow_url_fopen <font style="color:red">not loaded!</font><br />'; | |
} | |
else | |
{ | |
echo 'PHP module allow_url_fopen: <font style="color:red">Critical Error while finding the PHP module allow_url_fopen!</font><br />'; | |
} | |
/* checking getimagesize and allow_url_fopen */ | |
$info = @getimagesize('http://www.google.de/intl/de_de/images/logo.gif'); | |
if (!is_array($info)) | |
{ | |
$info = array('null' => 'null'); | |
echo 'Checking function getimagesize: <font style="color:red">is not working!</font> (May be something that\'s overwriting the php.ini directives. Contact your host.)<br />'; | |
} | |
else if (is_array($info)) | |
{ | |
echo 'Checking function getimagesize: <font style="color:green">is working.</font><br />'; | |
} | |
else | |
{ | |
echo 'Checking function getimagesize: <font style="color:red">Critical Error while checking function getimagesize. Contact your host.</font><br />'; | |
} | |
/* cookies for Olympus */ | |
if ($olympus) | |
{ | |
if (!empty($_SERVER['SERVER_NAME'])) | |
{ | |
$url = $_SERVER['SERVER_NAME']; | |
} | |
// Running on IIS? | |
if (!empty($_SERVER['LOCAL_ADDR'])) | |
{ | |
$url = $_SERVER['LOCAL_ADDR']; | |
} | |
} | |
/* cookies for Ascraeus/Rhea */ | |
else if (($ascraeus) || ($rhea) || (!$olympus)) | |
{ | |
$url = $request->server('SERVER_NAME', ''); | |
} | |
echo '<br /><font style="color:purple">Server name: </font><font style="color:blue">' . $url . '</font>'; | |
echo '<br /><font style="color:purple">Cookie domain: </font><font style="color:blue">' . $config['cookie_domain'] . '</font>'; | |
echo '<br /><font style="color:purple">Cookie name: </font><font style="color:blue">' . $config['cookie_name'] . '</font>'; | |
echo '<br /><font style="color:purple">Cookie path: </font><font style="color:blue">' . $config['cookie_path'] . '</font>'; | |
$secure = ($config['cookie_secure']) ? 'Enabled' : 'Disabled'; | |
echo '<br /><font style="color:purple">Cookie secure: </font><font style="color:blue">' . $secure . '</font>'; | |
echo '<br /><font style="color:purple">DB info: </font><font style="color:blue">' . $db->sql_server_info() . '</font>'; | |
echo '<br /><font style="color:purple">ImageMagick path: </font><font style="color:blue">' . $config['img_imagick'] . '</font>'; | |
/* Let's check some folders' perms */ | |
if ($perms = "0777") | |
{ | |
$perm_col = '</font><font style="color:green">' . $perms . '</font>'; | |
} | |
else | |
{ | |
$perm_col = '</font><font style="color:red">' . $perms . '</font>'; | |
} | |
$cache_dir = ($phpbb_root_path . 'cache'); | |
$perms = substr(sprintf('%o', fileperms($cache_dir)), -4); | |
echo '<br /><font style="color:purple">Cache folder chmod: </font>' . $perm_col . ''; | |
$store_dir = ($phpbb_root_path . 'store'); | |
$perms = substr(sprintf('%o', fileperms($store_dir)), -4); | |
echo '<br /><font style="color:purple">Store folder chmod: </font>' . $perm_col . ''; | |
$files_dir = ($phpbb_root_path . 'files'); | |
$perms = substr(sprintf('%o', fileperms($files_dir)), -4); | |
echo '<br /><font style="color:purple">Files folder chmod: ' . $perm_col . ''; | |
$av_up_dir = ($phpbb_root_path . 'images/avatars/upload'); | |
$perms = substr(sprintf('%o', fileperms($av_up_dir)), -4); | |
echo '<br /><font style="color:purple">Images/avatar/upload folder chmod: </font>' . $perm_col . ''; | |
/* Hasta la vista! */ | |
echo '<br /><font color="blue">Copy-paste these results or make a screenshot for further support...<br />...I am self destroying, hasta la vista!</font><br /><br />'; | |
echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="ZLN6KTV2WQSRN"><input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online."><img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"><font color="darkred"> Help the development of this Tool by a donation of your choice.</font></form>'; | |
/* uncomment the following line to turn on PHP info. */ | |
//phpinfo(); | |
/* comment out the following line to turn off the self-destroyer. */ | |
remove_me(); | |
} | |
else | |
{ | |
/* If logged in without the right permissions, stop everything and self-destroy */ | |
remove_me(); | |
trigger_error('You don\'t have permission to access the database and files. You need to be logged in as a founder or administrator.'); | |
} | |
/* Attempting to delete this file */ | |
function remove_me() | |
{ | |
@unlink(__FILE__); | |
/** Windows IIS servers may have a problem with unlinking recently created files. | |
* * So check if file exists and give a message | |
*/ | |
if (file_exists(__FILE__)) | |
{ | |
echo '<strong color="red">File could not be deleted.</strong> You will | |
need to manually delete the ' . basename(__FILE__) . ' file from the server.'; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment