public static function handleRequest()
 {
     if (extension_loaded('newrelic')) {
         newrelic_disable_autorum();
     }
     // retrieve authentication attempt
     if ($GLOBALS['Session']->hasAccountLevel('Developer')) {
         $User = $GLOBALS['Session']->Person;
     } else {
         $authEngine = new \Sabre\HTTP\BasicAuth();
         $authEngine->setRealm('Develop ' . \Site::$title);
         $authUserPass = $authEngine->getUserPass();
         // try to get user
         $userClass = \User::$defaultClass;
         $User = $userClass::getByLogin($authUserPass[0], $authUserPass[1]);
         // send auth request if login is inadiquate
         if (!$User || !$User->hasAccountLevel('Developer')) {
             $authEngine->requireLogin();
             die("You must login using a " . \Site::getConfig('primary_hostname') . " account with Developer access\n");
         }
     }
     // store login to session
     if (isset($GLOBALS['Session'])) {
         $GLOBALS['Session'] = $GLOBALS['Session']->changeClass('UserSession', array('PersonID' => $User->ID));
     }
     // detect base path
     $basePath = array_slice(\Site::$requestPath, 0, count(\Site::$resolvedPath));
     // switch to JSON response mode
     if (static::peekPath() == 'json') {
         $basePath[] = static::$responseMode = static::shiftPath();
     }
     // handle /develop request
     if ($_SERVER['REQUEST_METHOD'] == 'GET' && static::getResponseMode() == 'html' && !static::peekPath()) {
         \RequestHandler::respond('app/ext', array('App' => \Sencha_App::getByName('EmergenceEditor'), 'mode' => 'production', 'title' => 'EmergenceEditor'));
     }
     // initial and configure SabreDAV
     $server = new \Sabre\DAV\Server(new RootCollection());
     $server->setBaseUri('/' . join('/', $basePath));
     // The lock manager is reponsible for making sure users don't overwrite each others changes. Change 'data' to a different
     // directory, if you're storing your data somewhere else.
     #       $lockBackend = new Sabre_DAV_Locks_Backend_FS('/tmp/dav-lock');
     #       $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
     #       $server->addPlugin($lockPlugin);
     // filter temporary files
     $server->addPlugin(new \Sabre\DAV\TemporaryFileFilterPlugin('/tmp/dav-tmp'));
     // ?mount support
     $server->addPlugin(new \Sabre\DAV\Mount\Plugin());
     // emergence :)
     $server->addPlugin(new \Emergence\DAV\ServerPlugin());
     // All we need to do now, is to fire up the server
     $server->exec();
 }
 public function handleRequest($data)
 {
     parent::handleRequest($data);
     if (empty($data['Password'])) {
         throw new Exception('Enter a new password for your account');
     } elseif ($data['Password'] != $data['PasswordConfirm']) {
         throw new Exception('Enter your new password twice for confirmation');
     }
     $this->Creator->setClearPassword($data['Password']);
     $this->Creator->save();
     // set used
     $this->Used = time();
     $this->save();
     return RequestHandler::respond('register/passwordRecovered');
 }
Beispiel #3
0
<?php

$meetups = RemoteSystems\Meetup::getEvents();
$nextMeetup = array_shift($meetups);
// detect if meetup is happening right now
if ($nextMeetup && $nextMeetup['time'] < time() * 1000) {
    $currentMeetup = $nextMeetup;
    $checkins = Laddr\MemberCheckin::getAllByField('MeetupID', $currentMeetup['id'], array('order' => 'ID DESC'));
    $nextMeetup = array_shift($meetups);
}
RequestHandler::respond('bigscreen', array('currentMeetup' => $currentMeetup, 'checkins' => $checkins, 'nextMeetup' => $nextMeetup));
 public static function respond($responseID, $responseData = [], $responseMode = false)
 {
     return parent::respond($responseID, array_merge($responseData, []), $responseMode);
 }
Beispiel #5
0
<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    Site::$autoPull = true;
    Site::$debug = true;
    set_time_limit(0);
    $trees = array('dwoo-plugins', 'event-handlers', 'ext-library', 'html-templates', 'js-library', 'php-classes', 'php-config', 'phpunit-tests', 'php-migrations', 'site-root', 'sencha-workspace/.sencha', 'sencha-workspace/microloaders', 'sencha-workspace/pages', 'sencha-workspace/packages', 'sencha-workspace/EmergenceEditor', 'sencha-workspace/EmergencePullTool', 'sencha-workspace/ContentEditor');
    $message = "";
    foreach ($_POST['collections'] as $collection) {
        $filesCached = Emergence_FS::cacheTree($collection, true);
        $message .= sprintf('Precached %03u files in %s' . PHP_EOL, $filesCached, $collection);
    }
}
RequestHandler::respond('precache', array('message' => $message));
Beispiel #6
0
$pageData['projectsTags']['byEvent'] = TagItem::getTagsSummary(array('tagConditions' => array('Handle LIKE "event.%"'), 'itemConditions' => array('ContextClass' => Laddr\Project::getStaticRootClass())));
$pageData['projectsStages'] = Laddr\Project::getStagesSummary();
// members
$pageData['membersTotal'] = Emergence\People\Person::getCount();
$pageData['membersTags']['byTech'] = TagItem::getTagsSummary(array('tagConditions' => array('Handle LIKE "tech.%"'), 'itemConditions' => array('ContextClass' => Emergence\People\Person::getStaticRootClass())));
$pageData['membersTags']['byTopic'] = TagItem::getTagsSummary(array('tagConditions' => array('Handle LIKE "topic.%"'), 'itemConditions' => array('ContextClass' => Emergence\People\Person::getStaticRootClass())));
// build activity stream
if (!($pageData['activity'] = Cache::fetch('home-activity'))) {
    $existingTables = \DB::allValues('table_name', 'SELECT table_name FROM information_schema.TABLES WHERE TABLE_SCHEMA = SCHEMA()');
    $activityQueries = [];
    if (in_array(Emergence\CMS\AbstractContent::$tableName, $existingTables)) {
        $activityQueries[] = sprintf('SELECT' . '  ID, Class, Published AS Timestamp' . ' FROM `%s`' . ' WHERE' . '  Class = "%s" AND' . '  Visibility = "Public" AND' . '  Status = "Published" AND' . '  (Published IS NULL OR Published <= CURRENT_TIMESTAMP)', Emergence\CMS\AbstractContent::$tableName, DB::escape(Emergence\CMS\BlogPost::class));
    }
    if (in_array(Laddr\ProjectUpdate::$tableName, $existingTables)) {
        $activityQueries[] = sprintf('SELECT ID, Class, Created AS Timestamp FROM `%s`', Laddr\ProjectUpdate::$tableName);
    }
    if (in_array(Laddr\ProjectBuzz::$tableName, $existingTables)) {
        $activityQueries[] = sprintf('SELECT ID, Class, Published AS Timestamp FROM `%s`', Laddr\ProjectBuzz::$tableName);
    }
    if (count($activityQueries)) {
        $pageData['activity'] = array_map(function ($result) {
            return $result['Class']::getByID($result['ID']);
        }, DB::allRecords(implode(' UNION ', $activityQueries) . ' ORDER BY Timestamp DESC LIMIT 10'));
    } else {
        $pageData['activity'] = [];
    }
    Cache::store('home-activity', $pageData['activity'], 30);
}
// render data against home template
RequestHandler::respond('home', $pageData);
Beispiel #7
0
<?php

RequestHandler::respond('how-to-help');
 public static function respond($responseID, $responseData = array(), $responseMode = false)
 {
     $responseData['connectorBaseUrl'] = static::_getConnectorBaseUrl();
     return parent::respond($responseID, $responseData, $responseMode);
 }
Beispiel #9
0
<?php

$GLOBALS['Session']->requireAccountLevel('Staff');
RequestHandler::respond('manage');
Beispiel #10
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())));
 /**
  * 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));
 }
Beispiel #12
0
<?php

$GLOBALS['Session']->requireAccountLevel('Administrator');
if (!empty($_POST['username'])) {
    if (!($User = User::getByUsername($_POST['username']))) {
        RequestHandler::throwNotFoundError('Username/email not found');
    }
    $GLOBALS['Session']->Person = $User;
    $GLOBALS['Session']->save();
    RequestHandler::respond('message', array('message' => sprintf('You are now logged in as %s. Logout and then log back into your normal account when you are finished.', $User->Username)));
}
RequestHandler::respond('masquerade');
Beispiel #13
0
<?php

RequestHandler::respond('resources');
Beispiel #14
0
<?php

RequestHandler::respond('mission');
<?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));
}
Beispiel #16
0
<?php

RequestHandler::respond('home');