public static function silent($user) { // Make sure the user doesn't exist if (is_numeric($user)) { if ($userData = User::get($user, "uni_id")) { return true; } } else { if ($userData = User::getIDByHandle($user)) { return true; } } // Get User Data from Auth $packet = array("user" => $user, "columns" => "uni_id, handle, display_name"); if ($response = API_Connect::to("auth", "UserData", $packet)) { return self::register((int) $response['uni_id'], $response['handle'], $response['display_name'], ""); } return false; }
} // 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";
public static function logActivity() { // Not ready yet API_Connect::to("karma", "KarmaActivityAPI", array("uni_id" => Me::$id, "site_handle" => SITE_HANDLE, "action" => "view")); }
<?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 '
$_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']) : ""; // Run the Form if (Form::submitted("install-app-config")) { // Check if all of the input you sent is valid: Validate::variable("Site Handle", $_POST['site-handle'], 3, 22); Validate::safeword("Site Name", $_POST['site-name'], 3, 42); Validate::url("URL", $_POST['site-url'], 3, 64); // Parse the URL input $siteURL = URL::parse($_POST['site-url']); if (Validate::pass()) { // Make sure the site handle isn't taken $packet = array("site-handle" => $_POST['site-handle'], "uni-handle" => $ownerHandle, "site-name" => $_POST['site-name'], "site-url" => $siteURL['full']); // Call UniFaction's API to register a site with the system // If the site fails to register, it will provide an alert explaining why $response = API_Connect::call(URL::unifaction_com() . "/api/RegisterSiteHandle", $packet); if ($response) { // If the database users are provided and there is a database name that we can create, build config settings $siteTheme = "default"; $siteThemeStyle = "default"; $buildApp = '<?php // Site-Wide Salt define("SITE_SALT", "' . $_POST['site-salt'] . '"); // A unique 10-22 alphanumeric value to represent your site define("SITE_HANDLE", "' . $_POST['site-handle'] . '"); // Set the Application Path (in most cases, this is the same as SITE_PATH) define("APP_PATH", SITE_PATH);
} // Make sure the content exists if ($contentData = Database::selectOne("SELECT id, uni_id, url, url_slug FROM content_entries WHERE id=? LIMIT 1", array((int) $_POST['contentID']))) { // Prepare Values $contentID = (int) $contentData['id']; $authorID = (int) $contentData['uni_id']; // If the entry was aggregated from another site if ($contentData['url']) { // Prepare the Packet $packet = array("uni_id" => Me::$id, "url_slug" => $contentData['url_slug'], "type" => "boost"); if (isset($_POST['voteType'])) { $packet["voteType"] = (int) $_POST['voteType']; } $articleSite = Database::selectValue("SELECT site_handle FROM network_data WHERE site_url=?", array($contentData['url'])); // Run the API $response = API_Connect::to($articleSite, "TrackerAPI", $packet); echo json_encode($response); exit; } // Run the Content Track Handler $contentTrack = new ContentTrack($contentID, Me::$id); switch ($_POST['type']) { case "boost": $contentTrack->voteUp(); break; case "nooch": $success = false; $noochCount = 0; if ($authorID != Me::$id) { // Check if the user has already triple nooched $noochCount = Database::selectValue("SELECT nooch FROM content_tracking_users WHERE uni_id=? AND content_id=? LIMIT 1", array(Me::$id, $contentID));
if (isset($_POST['send_email'])) { // Email a verification letter AppVerification::sendVerification($uniID); Alert::success("Email Sent", "The account was created successfully! A verification email has been sent to " . $_POST['email'] . "!"); } else { Alert::success("User Added", "The account was created successfully!"); } } } // Create the account if ($uniID) { $pass = Database::query("INSERT INTO users_handles (handle, uni_id) VALUES (?, ?)", array($_POST['handle'], $uniID)); if (Database::endTransaction($pass)) { // Create the ProfilePic for this Account $packet = array("uni_id" => $uniID, "title" => $_POST['display_name']); $response = API_Connect::to("profile_picture", "SetDefaultPic", $packet); // Reset Values $_POST['handle'] = ""; $_POST['display_name'] = ""; $_POST['email'] = ""; $_POST['password'] = ""; } } else { Database::endTransaction(false); Alert::error("Process Error", "An error has occurred while processing this registration.", 1); } } } else { $_POST['email'] = isset($_POST['email']) ? Sanitize::email($_POST['email']) : ""; $_POST['password'] = isset($_POST['password']) ? Sanitize::safeword($_POST['password']) : ""; $_POST['handle'] = isset($_POST['handle']) ? Sanitize::variable($_POST['handle']) : "";