Example #1
0
 public static function server()
 {
     // Log the user out of the server
     Cookie_Server::deleteAll();
     // Remove the Session Values
     unset($_SESSION['login']);
     unset($_SESSION['uni_id']);
     unset($_SESSION['user']);
 }
Example #2
0
<?php

// Destroy all cookies and sessions
Cookie_Server::deleteAll();
session_destroy();
unset($_SESSION);
unset($_COOKIE);
// Installation Header
require dirname(ROUTE_SECOND_PATH) . "/includes/install_header.php";
// Run Global Script
require dirname(ROUTE_SECOND_PATH) . "/includes/install_global.php";
// Display the Header
require dirname(ROUTE_SECOND_PATH) . "/includes/admin_header.php";
echo '
<h1>Installation</h1>
<p>Welcome to the installer! This installer will walk you through the necessary steps to set up your application (your site).</p>

<h3>Helpful Notes</h3>
<p>Here are a few helpful pointers that may help you understand certain elements of installation:</p>

<p>
<strong>User Handles:</strong>
<br />A "handle" (or "user handle") is the username of one of your UniFaction users (profiles). Handles are often indicated by a "@" sign, such as "@joesmith1" or "@spiderman", and are important for referencing other users on UniFaction.

<br /><br />To access one of your user handles, log into your UniFaction account and click on one of your users. The user that you click on should tell you what your handle is.

<br /><br />The installation will prompt you for your administrator handle. The user you choose (by entering it\'s handle) will be granted admin rights to your site.

<br /><br /><strong>Site Handles:</strong>
<br />A "site handle" is different than a "user handle". You can think of it like referencing your site rather than a UniFaction user. Your site handle will allow UniFaction (and other sites connected to UniFaction) to identify your site and interact with it.
<?php

// Installation Header
require PARENT_APP_PATH . "/includes/install_header.php";
// Run the Form
if (Form::submitted("install-connect-handle")) {
    // Check if all of the input you sent is valid:
    $_POST['handle'] = str_replace("@", "", $_POST['handle']);
    Validate::variable("UniFaction Handle", $_POST['handle'], 1, 22);
    if (Validate::pass()) {
        // Make sure the handle is registered
        if ($response = API_Connect::call(URL::unifaction_com() . "/api/UserRegistered", $_POST['handle'])) {
            Cookie_Server::set("admin-handle", $_POST['handle'], "", 3);
            Alert::saveSuccess("Admin Chosen", "You have designated @" . $_POST['handle'] . " as the admin of your site.");
            header("Location: /install/config-app");
            exit;
        } else {
            Alert::error("Handle Invalid", "That user handle does not exist on UniFaction.");
        }
    }
} else {
    $_POST['handle'] = isset($_POST['handle']) ? Sanitize::variable($_POST['handle']) : "";
}
// Run Global Script
require PARENT_APP_PATH . "/includes/install_global.php";
// Display the Header
require HEADER_PATH;
echo '
<form class="uniform" action="/install/connect-handle" method="post">' . Form::prepare("install-connect-handle");
// Display the Page
echo '
Example #4
0
<?php

// Installation Header
require PARENT_APP_PATH . "/includes/install_header.php";
// Make sure you have a designated handle
if (!($ownerHandle = Cookie_Server::get("admin-handle", ""))) {
    header("Location: /install/connect-handle");
    exit;
}
// If the form was not submitted, set the $_POST values to the default configuration values.
// This will allow us to auto-fill the form with useful data, rather than leaving them all empty.
if (!isset($_POST['site-salt']) and isset(Config::$siteConfig['database'])) {
    $_POST['site-salt'] = SITE_SALT;
    $_POST['site-handle'] = SITE_HANDLE;
    $_POST['site-url'] = SITE_URL;
    $_POST['site-name'] = Config::$siteConfig['Site Name'];
    $_POST['site-domain'] = FULL_DOMAIN;
    $_POST['site-database-name'] = Database::$databaseName;
}
// Prepare Installation Values
$buildApp = "";
$randSalt = Security_Hash::random(82, 80);
$randSalt = str_replace('"', '', $randSalt);
$randSalt = str_replace('$', '', $randSalt);
// Prepare POST Values: make sure that every $_POST value has a default value provided.
$_POST['site-salt'] = isset($_POST['site-salt']) ? Sanitize::text($_POST['site-salt']) : $randSalt;
$_POST['site-handle'] = isset($_POST['site-handle']) ? Sanitize::variable($_POST['site-handle']) : "";
$_POST['site-url'] = isset($_POST['site-url']) ? Sanitize::variable($_POST['site-url'], ":/.") : $_SERVER['SERVER_NAME'];
$_POST['site-name'] = isset($_POST['site-name']) ? Sanitize::text($_POST['site-name']) : "";
$_POST['site-domain'] = isset($_POST['site-domain']) ? Sanitize::variable($_POST['site-domain'], ":/.") : "";
$_POST['site-database-name'] = isset($_POST['site-database-name']) ? Sanitize::variable($_POST['site-database-name']) : "";