Created
February 12, 2017 13:56
-
-
Save woganmay/4a08dd348fdaec3900c6f0cb6c6e3b08 to your computer and use it in GitHub Desktop.
Check for Flarum authentication before the main site even loads
This file contains 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 | |
if (isset($_COOKIE['flarum_remember'])) | |
{ | |
$mysql = new mysqli("localhost", "flarum_sql_user", "flarum_sql_pass", "flarum_database"); | |
$result = $mysql->query("SELECT * FROM access_tokens WHERE id = '". $mysql->real_escape_string($_COOKIE['flarum_remember']) ."'"); | |
if ($result->num_rows == 0) | |
{ | |
// Invalid cookie | |
header('Location:https://my.laravel.site/login'); | |
exit; | |
} | |
} | |
else | |
{ | |
// No cookie | |
header('Location:https://my.laravel.site/login'); | |
exit; | |
} | |
// Rest of normal index.php here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment