}
// Prepare Values
set_time_limit(300);
// Set the timeout limit to 5 minutes.
// Run Header
require SYS_PATH . "/controller/includes/admin_header.php";
// Run Global Script (if applicable)
if (isset($_GET['action']) and $_GET['action'] == "run") {
    Database::initRoot();
    echo "Running Script:<br />";
    // Prepare Valuess
    define("PROTECTED", true);
    // Gather Sites
    $siteList = Database::selectMultiple("SELECT site_handle, site_name FROM network_data", array());
    foreach ($siteList as $site) {
        $apiData = API_Data::get($site['site_handle']);
        $success = API_Connect::call($apiData['site_url'] . "/api/AuthCommand", "system-script", $apiData['site_key']);
        if ($success) {
            echo "<br /><span style='color:green;'>" . $site['site_name'] . " run their instructions SUCCESSFULLY!</span>";
        } else {
            echo "<br /><span style='color:red;'>" . $site['site_name'] . " FAILED! Some or all of the instructions did not run as desired.</span>";
        }
    }
    echo "<br /><br />Script Complete.";
} else {
    echo '
	<p>Are you sure you want to have all sites run the system-wide script "{SYS_PATH}/system-script.php" on the entire universe system?</p>
	<p><a class="button" href="/admin/scripts/run-universe?action=run">Yes, run the script</a></p>';
}
// Display the Footer
require SYS_PATH . "/controller/includes/admin_footer.php";
Example #2
0
This script will return the user to the last known "Return URL", which is the location that was previously stored by the user's session to identify where they should return to after a redirect.

This is most likely called after an attempt for automatically logging in to Auth that failed (due to Auth not being logged in).
*/
// Make sure the Return URL exists
if (!isset($_SESSION['login']['return_url'])) {
    unset($_SESSION['login']);
    header("Location: /");
    exit;
}
// If you're already logged in, return to the Return URL
if (Me::$id) {
    header("Location: /" . $_SESSION['login']['return_url']);
    exit;
}
// Retrieve the Site Key
$apiData = API_Data::get("auth");
// Save the site handshake
$_SESSION['login']['handshake'] = Security_Hash::random(30, 62);
// Prepare Custom Data
$customData = array("handshake" => $_SESSION['login']['handshake']);
// If we're making an auto-login action, inform Auth so that it can react appropriately
if (isset($_GET['action']) and $_GET['action'] == "autolog") {
    $customData['autolog'] = true;
}
// Create a query string with valid packet data
$queryStringPacket = API_PacketEncrypt::queryString($customData, $apiData['site_key']);
// Redirect to Auth's Automatic Login Page (Get credentials and return)
header("Location: " . $apiData['site_url'] . "/login-auto?" . $queryStringPacket);
exit;
Example #3
0
    // If this page was referred by a previous URL
    if (isset($_SERVER['HTTP_REFERER'])) {
        $refURL = URL::parse($_SERVER['HTTP_REFERER']);
        $_SESSION['login']['return_url'] = '/' . (isset($refURL['path']) ? $refURL['path'] : '') . (isset($refURL['query']) ? '?' . $refURL['query'] : '');
    } else {
        $_SESSION['login']['return_url'] = '/';
    }
}
// If you're already logged in, return to the Return URL
if (Me::$id) {
    unset($_SESSION['login']);
    header("Location: /" . $_SESSION['login']['return_url']);
    exit;
}
// Retrieve the Site Key
if (!($apiData = API_Data::get("auth"))) {
    die("Error: Unable to retrieve proper authentication.");
}
// Save the site handshake
$_SESSION['login']['handshake'] = Security_Hash::random(30, 62);
// Prepare Custom Data
$customData = array("handshake" => $_SESSION['login']['handshake']);
// If we're making an auto-login action, inform Auth so that it can react appropriately
if (isset($_GET['action']) and $_GET['action'] == "autolog") {
    $customData['autolog'] = true;
}
// Create a query string with valid packet data
$queryStringPacket = API_PacketEncrypt::queryString($customData, $apiData['site_key']);
// Redirect to Auth's Automatic Login Page (Get credentials and return)
header("Location: " . $apiData['site_url'] . "/login-auto?" . $queryStringPacket);
exit;