/**
  * Print login page and exit
  * @return nothing
  * @param object $AuthException[optional]
  */
 public function respondLoginPrompt($authException = false)
 {
     if (Site::$pathStack[0] == 'json' || $_REQUEST['format'] == 'json' || $_SERVER['HTTP_ACCEPT'] == 'application/json') {
         RequestHandler::$responseMode = 'json';
     }
     header('HTTP/1.1 401 Unauthorized');
     $postVars = $_POST;
     unset($postVars[static::$requestContainer]);
     RequestHandler::respond('login/login', array('success' => false, 'loginRequired' => true, 'requestContainer' => static::$requestContainer, 'error' => $authException ? $authException->getMessage() : false, 'postVars' => $postVars));
 }
Exemplo n.º 2
0
<?php

RequestHandler::$responseMode = 'csv';
RequestHandler::respond('projects', array('data' => array_map(function ($Project) {
    preg_match('/^\\s*[^*#]\\s*\\w.*/m', $Project->README, $matches);
    return array('name' => $Project->Title, 'description' => trim($matches[0]), 'link_url' => $Project->UsersUrl, 'code_url' => $Project->DevelopersUrl, 'type' => '', 'categories' => implode(', ', array_map(function ($Tag) {
        return $Tag->UnprefixedTitle;
    }, array_filter($Project->Tags, function ($Tag) {
        return $Tag->Prefix == 'topic';
    }))));
}, Laddr\Project::getAll())));
Exemplo n.º 3
0
<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
set_time_limit(0);
RequestHandler::$responseMode = 'json';
if (empty($_REQUEST['path'])) {
    RequestHandler::throwError('path required');
}
if (empty($_REQUEST['host'])) {
    RequestHandler::throwError('host required');
}
if (!($sourceCollection = Site::resolvePath($_REQUEST['path']))) {
    RequestHandler::throwError('path not found locally');
}
// create stream context for remote server
$syncer = new EmergenceSyncer(array('host' => $_REQUEST['host'], 'authUsername' => $_SERVER['PHP_AUTH_USER'], 'authPassword' => $_SERVER['PHP_AUTH_PW']));
$diff = $syncer->diffCollection($sourceCollection, !empty($_REQUEST['deep']));
if (empty($_REQUEST['push'])) {
    RequestHandler::respond('diff', array('diff' => $diff));
} else {
    $result = $syncer->pushDiff($diff);
    RequestHandler::respond('pushComplete', array('result' => $result));
}