Ejemplo n.º 1
0
Archivo: sso.php Proyecto: uinerd/Code
 /**
  * If there is a new session for this user/server, append the token request to the page
  */
 public static function appendTokenRequest()
 {
     $cmd = self::$cmd;
     $session = LigminchaGlobalSession::getCurrent();
     // If there is a current session,
     if ($session) {
         // If the session is newly created, get an SSO cookie under ligmincha.org for this session ID
         // - newly created sessions have no expiry
         // - this is done by appending a 1x1pixel iFrame to the output that will request a token cookie from ligmincha.org
         if ($session->flag(LG_NEW)) {
             // We always set a local cookie as well so we can get the current session ID from it
             self::setCookie($session->id);
             // Otherwise we need to make the request to the master in the iFrame
             if (!LigminchaGlobalServer::getCurrent()->isMaster) {
                 $url = LigminchaGlobalServer::masterDomain();
                 $iframe = "<iframe src=\"http://{$url}?{$cmd}={$session->id}\" frameborder=\"0\" width=\"1\" height=\"1\"></iframe>";
                 $app = JFactory::getApplication('site');
                 $app->setBody(str_replace('</body>', "{$iframe}\n</body>", $app->getBody()));
                 lgDebug("SSO cookie request iFrame added to page ({$url})", $session);
             }
             // Set the expiry to a longer time that distributed sessions last
             // - after it expires, user needs to come back to have another made (may not need to log in again)
             $session->expire = LigminchaGlobalObject::timestamp() + LG_SESSION_DURATION;
             // Now that the session is real it can route
             $session->flag(LG_LOCAL, false);
             // Write changes to the session object into the distributed database
             $session->update();
         }
     }
 }
Ejemplo n.º 2
0
<?php

// Load the code common to standalone functionality
include __DIR__ . '/standalone.php';
// These are the global objects made initially available to the app (only server objects are available if not logged in)
$types = array(LG_SERVER, LG_LOG);
if ($session) {
    $types[] = LG_USER;
    $types[] = LG_SESSION;
}
$objects = LigminchaGlobalObject::select(array('type' => $types));
$wgOut->addJsConfigVars('GlobalObjects', $objects);
$wgOut->addJsConfigVars('toolbar', false);
// Make the ID of the master server known to the client-side
$wgOut->addJsConfigVars('masterServer', LigminchaGlobalServer::getMaster()->id);
// Get the list of tags from the Github repo
$config = JFactory::getConfig();
$auth = $config->get('lgRepoAuth');
$repoTags = array();
//json_decode( LigminchaGlobalDistributed::get( 'https://api.github.com/repos/Ligmincha/Code/tags', $auth ) );
$tags = array();
foreach ($repoTags as $tag) {
    if (preg_match('/^v([0-9.]+)/', $tag->name)) {
        $tags[$tag->name] = $tag->tarball_url;
    }
}
$wgOut->addJsConfigVars('tags', $tags);
?>
<!DOCTYPE html>
<html lang="en">
	<head>
Ejemplo n.º 3
0
 public static function selectOne($cond = array())
 {
     $cond['type'] = LG_VERSION;
     return parent::selectOne($cond);
 }
Ejemplo n.º 4
0
 /**
  * This is the update interface used by incoming sync objects being processed
  * - Create a local object from the sync object so we can call the regular update method on it
  */
 public static function update($fields, $origin)
 {
     if (!is_array($fields)) {
         die('Fields must be an array');
     }
     $obj = LigminchaGlobalObject::newFromFields($fields);
     $obj->exists = (bool) self::getObject($obj->id);
     $obj->update($origin);
 }