本文整理汇总了PHP中RequestHandler::respond方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestHandler::respond方法的具体用法?PHP RequestHandler::respond怎么用?PHP RequestHandler::respond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestHandler
的用法示例。
在下文中一共展示了RequestHandler::respond方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
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();
}
示例2: handleRequest
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');
}
示例3: array_shift
<?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));
示例4: respond
public static function respond($responseID, $responseData = [], $responseMode = false)
{
return parent::respond($responseID, array_merge($responseData, []), $responseMode);
}
示例5: set_time_limit
<?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));
示例6: array
$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);
示例7:
<?php
RequestHandler::respond('how-to-help');
示例8: respond
public static function respond($responseID, $responseData = array(), $responseMode = false)
{
$responseData['connectorBaseUrl'] = static::_getConnectorBaseUrl();
return parent::respond($responseID, $responseData, $responseMode);
}
示例9:
<?php
$GLOBALS['Session']->requireAccountLevel('Staff');
RequestHandler::respond('manage');
示例10: array
<?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())));
示例11: respondLoginPrompt
/**
* 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));
}
示例12: array
<?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');
示例13: set_time_limit
<?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));
}