本文整理匯總了PHP中DevblocksPlatform::getSessionService方法的典型用法代碼示例。如果您正苦於以下問題:PHP DevblocksPlatform::getSessionService方法的具體用法?PHP DevblocksPlatform::getSessionService怎麽用?PHP DevblocksPlatform::getSessionService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DevblocksPlatform
的用法示例。
在下文中一共展示了DevblocksPlatform::getSessionService方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isVisible
function isVisible()
{
// check login
$session = DevblocksPlatform::getSessionService();
$visit = $session->getVisit();
if (empty($visit)) {
return false;
} else {
return true;
}
}
示例2: authenticate
function authenticate()
{
// Pull from $_POST
@($email = DevblocksPlatform::importGPC($_POST['email']));
@($password = DevblocksPlatform::importGPC($_POST['password']));
$worker = DAO_Worker::login($email, $password);
if (!is_null($worker)) {
$session = DevblocksPlatform::getSessionService();
$visit = new CerberusVisit();
$visit->setWorker($worker);
$session->setVisit($visit);
// [TODO] Only direct to /welcome when tour is enabled
return true;
} else {
return false;
}
}
示例3: writeResponse
public function writeResponse(DevblocksHttpResponse $response)
{
$path = $response->path;
// [JAS]: Ajax? // [TODO] Explore outputting whitespace here for Safari
// if(empty($path))
// return;
$tpl = DevblocksPlatform::getTemplateService();
$session = DevblocksPlatform::getSessionService();
$settings = CerberusSettings::getInstance();
$translate = DevblocksPlatform::getTranslationService();
$active_worker = CerberusApplication::getActiveWorker();
$visit = $session->getVisit();
$page_manifests = $this->_getAllowedPages();
$controller = array_shift($path);
// Default page [TODO] This is supposed to come from framework.config.php
if (empty($controller)) {
$controller = 'home';
}
// [JAS]: Require us to always be logged in for Cerberus pages
if (empty($visit) && 0 != strcasecmp($controller, 'login')) {
$query = array();
if (!empty($response->path)) {
$query = array('url' => urlencode(implode('/', $response->path)));
}
DevblocksPlatform::redirect(new DevblocksHttpRequest(array('login'), $query));
}
$page_id = $this->_getPageIdByUri($controller);
@($page = DevblocksPlatform::getExtension($page_id, true));
/* @var $page CerberusPageExtension */
if (empty($page)) {
header("Status: 404");
return;
// [TODO] 404
}
// [JAS]: Listeners (Step-by-step guided tour, etc.)
$listenerManifests = DevblocksPlatform::getExtensions('devblocks.listener.http');
foreach ($listenerManifests as $listenerManifest) {
/* @var $listenerManifest DevblocksExtensionManifest */
$inst = $listenerManifest->createInstance();
/* @var $inst DevblocksHttpRequestListenerExtension */
$inst->run($response, $tpl);
}
$tpl->assign('active_worker', $active_worker);
$tour_enabled = false;
if (!empty($visit) && !is_null($active_worker)) {
$tour_enabled = intval(DAO_WorkerPref::get($active_worker->id, 'assist_mode', 1));
if (DEMO_MODE) {
$tour_enabled = 1;
}
// override for DEMO
$keyboard_shortcuts = intval(DAO_WorkerPref::get($active_worker->id, 'keyboard_shortcuts', 1));
$tpl->assign('pref_keyboard_shortcuts', $keyboard_shortcuts);
$active_worker_memberships = $active_worker->getMemberships();
$tpl->assign('active_worker_memberships', $active_worker_memberships);
$unread_notifications = DAO_WorkerEvent::getUnreadCountByWorker($active_worker->id);
$tpl->assign('active_worker_notify_count', $unread_notifications);
DAO_Worker::logActivity($active_worker->id, $page->getActivity());
}
$tpl->assign('tour_enabled', $tour_enabled);
// [JAS]: Variables provided to all page templates
$tpl->assign('settings', $settings);
$tpl->assign('session', $_SESSION);
$tpl->assign('translate', $translate);
$tpl->assign('visit', $visit);
$tpl->assign('license', CerberusLicense::getInstance());
$tpl->assign('page_manifests', $page_manifests);
$tpl->assign('page', $page);
$tpl->assign('response_uri', implode('/', $response->path));
$core_tpl = DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/';
$tpl->assign('core_tpl', $core_tpl);
// Prebody Renderers
$preBodyRenderers = DevblocksPlatform::getExtensions('cerberusweb.renderer.prebody', true);
if (!empty($preBodyRenderers)) {
$tpl->assign('prebody_renderers', $preBodyRenderers);
}
// Postbody Renderers
$postBodyRenderers = DevblocksPlatform::getExtensions('cerberusweb.renderer.postbody', true);
if (!empty($postBodyRenderers)) {
$tpl->assign('postbody_renderers', $postBodyRenderers);
}
// Timings
$tpl->assign('render_time', microtime(true) - DevblocksPlatform::getStartTime());
if (function_exists('memory_get_usage') && function_exists('memory_get_peak_usage')) {
$tpl->assign('render_memory', memory_get_usage() - DevblocksPlatform::getStartMemory());
$tpl->assign('render_peak_memory', memory_get_peak_usage() - DevblocksPlatform::getStartPeakMemory());
}
$tpl->display($core_tpl . 'border.tpl');
// $cache = DevblocksPlatform::getCacheService();
// $cache->printStatistics();
}
示例4: authenticate
function authenticate($params = array())
{
$server = $params['server'];
$port = $params['port'];
$dn = $params['dn'];
$password = $params['password'];
$worker_id = null;
// attempt login
$conn = ldap_connect($server, $port);
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($conn) {
$auth = ldap_bind($conn, $dn, $password);
if ($auth) {
// search for this user
$search_results = ldap_search($conn, $dn, '(objectclass=*)', array('mail'));
if ($search_results) {
$user_entry = ldap_first_entry($conn, $search_results);
if ($user_entry) {
// get email addresses for this user
$emails = ldap_get_values($conn, $user_entry, 'mail');
if ($emails) {
foreach ($emails as $email) {
if (is_null($worker_id)) {
$worker_id = DAO_Worker::lookupAgentEmail($email);
}
}
}
}
}
}
}
// we found a worker, continue login
if (!is_null($worker_id)) {
$worker = DAO_Worker::getAgent($worker_id);
$session = DevblocksPlatform::getSessionService();
$visit = new CerberusVisit();
$visit->setWorker($worker);
$session->setVisit($visit);
return true;
} else {
return false;
}
}
示例5: signoutAction
function signoutAction()
{
$session = DevblocksPlatform::getSessionService();
$visit = $session->getVisit();
if (null != ($worker = CerberusApplication::getActiveWorker())) {
DAO_Worker::logActivity($worker->id, new Model_Activity(null));
}
$session->clear();
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login')));
}
示例6: getVisit
/**
* @return CerberusVisit
*/
static function getVisit()
{
$session = DevblocksPlatform::getSessionService();
return $session->getVisit();
}
示例7: handleRequest
function handleRequest(DevblocksHttpRequest $request)
{
@set_time_limit(0);
// no timelimit (when possible)
$translate = DevblocksPlatform::getTranslationService();
$stack = $request->path;
array_shift($stack);
// update
$cache = DevblocksPlatform::getCacheService();
/* @var $cache _DevblocksCacheManager */
switch (array_shift($stack)) {
case 'locked':
if (!DevblocksPlatform::versionConsistencyCheck()) {
$url = DevblocksPlatform::getUrlService();
echo "<h1>Feg - Fax Email Gateway 1.x</h1>";
echo "The application is currently waiting for an administrator to finish upgrading. " . "Please wait a few minutes and then " . sprintf("<a href='%s'>try again</a>.<br><br>", $url->write('c=update&a=locked'));
echo sprintf("If you're an admin you may <a href='%s'>finish the upgrade</a>.", $url->write('c=update'));
} else {
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login')));
}
break;
default:
$path = APP_TEMP_PATH . DIRECTORY_SEPARATOR;
$file = $path . 'feg_update_lock';
$settings = DevblocksPlatform::getPluginSettingsService();
$authorized_ips_str = $settings->get('feg.core', FegSettings::AUTHORIZED_IPS);
$authorized_ips = DevblocksPlatform::parseCrlfString($authorized_ips_str);
$authorized_ip_defaults = DevblocksPlatform::parseCsvString(AUTHORIZED_IPS_DEFAULTS);
$authorized_ips = array_merge($authorized_ips, $authorized_ip_defaults);
// Is this IP authorized?
$pass = false;
foreach ($authorized_ips as $ip) {
if (substr($ip, 0, strlen($ip)) == substr($_SERVER['REMOTE_ADDR'], 0, strlen($ip))) {
$pass = true;
break;
}
}
if (!$pass) {
echo vsprintf($translate->_('update.ip_unauthorized'), $_SERVER['REMOTE_ADDR']);
return;
}
// Check requirements
$errors = FegApplication::checkRequirements();
if (!empty($errors)) {
echo $translate->_('update.correct_errors');
echo "<ul style='color:red;'>";
foreach ($errors as $error) {
echo "<li>" . $error . "</li>";
}
echo "</ul>";
exit;
}
try {
// If authorized, lock and attempt update
if (!file_exists($file) || @filectime($file) + 600 < time()) {
// 10 min lock
// Log everybody out since we're touching the database
$session = DevblocksPlatform::getSessionService();
$session->clearAll();
// Lock file
touch($file);
// Recursive patch
FegApplication::update();
// Clean up
@unlink($file);
$cache = DevblocksPlatform::getCacheService();
$cache->save(APP_BUILD, "devblocks_app_build");
// Clear all caches
$cache->clean();
DevblocksPlatform::getClassLoaderService()->destroy();
// Clear compiled templates
$tpl = DevblocksPlatform::getTemplateService();
$tpl->utility->clearCompiledTemplate();
$tpl->cache->clearAll();
// Reload plugin translations
DAO_Translation::reloadPluginStrings();
// Redirect
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login')));
} else {
echo $translate->_('update.locked_another');
}
} catch (Exception $e) {
unlink($file);
die($e->getMessage());
}
}
exit;
}
示例8: header
if ('' == APP_DB_DRIVER || '' == APP_DB_HOST || '' == APP_DB_DATABASE || null == ($db = DevblocksPlatform::getDatabaseService()) || DevblocksPlatform::isDatabaseEmpty()) {
header('Location: ' . dirname($_SERVER['PHP_SELF']) . '/install/index.php');
// [TODO] change this to a meta redirect
exit;
}
require APP_PATH . '/api/Application.class.php';
DevblocksPlatform::init();
DevblocksPlatform::setExtensionDelegate('C4_DevblocksExtensionDelegate');
// Request
$request = DevblocksPlatform::readRequest();
// Patches (if not on the patch page)
if (@0 != strcasecmp(@$request->path[0], "update") && !DevblocksPlatform::versionConsistencyCheck()) {
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('update', 'locked')));
}
//DevblocksPlatform::readPlugins();
$session = DevblocksPlatform::getSessionService();
// Localization
DevblocksPlatform::setLocale(isset($_SESSION['locale']) && !empty($_SESSION['locale']) ? $_SESSION['locale'] : 'en_US');
if (isset($_SESSION['timezone'])) {
@date_default_timezone_set($_SESSION['timezone']);
}
// Initialize Logging
if (method_exists('DevblocksPlatform', 'getConsoleLog')) {
$timeout = ini_get('max_execution_time');
$logger = DevblocksPlatform::getConsoleLog();
$logger->info("[Devblocks] ** Platform starting (" . date("r") . ") **");
$logger->info('[Devblocks] Time Limit: ' . ($timeout ? $timeout : 'unlimited') . " secs");
$logger->info('[Devblocks] Memory Limit: ' . ini_get('memory_limit'));
}
// [JAS]: HTTP Request (App->Platform)
CerberusApplication::processRequest($request);
示例9: authenticateAction
function authenticateAction()
{
//echo "authing!";
@($email = DevblocksPlatform::importGPC($_POST['email']));
@($password = DevblocksPlatform::importGPC($_POST['password']));
// pull auth info out of $_POST, check it, return user_id or false
$worker = DAO_Worker::login($email, $password);
//echo $email. '-'.$password;print_r($worker);exit();
if (!is_null($worker)) {
$session = DevblocksPlatform::getSessionService();
$visit = new CerberusVisit();
$visit->setWorker($worker);
$session->setVisit($visit);
//$devblocks_response = new DevblocksHttpResponse(array('mobile','mytickets'));
$devblocks_response = new DevblocksHttpResponse(array('mobile', 'tickets'));
} else {
$devblocks_response = new DevblocksHttpResponse(array('mobile', 'login'));
//return false;
}
DevblocksPlatform::redirect($devblocks_response);
}
示例10: saveDefaultsAction
function saveDefaultsAction()
{
@($timezone = DevblocksPlatform::importGPC($_REQUEST['timezone'], 'string'));
@($lang_code = DevblocksPlatform::importGPC($_REQUEST['lang_code'], 'string', 'en_US'));
@($default_signature = DevblocksPlatform::importGPC($_REQUEST['default_signature'], 'string'));
@($default_signature_pos = DevblocksPlatform::importGPC($_REQUEST['default_signature_pos'], 'integer', 0));
@($reply_box_height = DevblocksPlatform::importGPC($_REQUEST['reply_box_height'], 'integer'));
$worker = CerberusApplication::getActiveWorker();
$translate = DevblocksPlatform::getTranslationService();
$tpl = DevblocksPlatform::getTemplateService();
$pref_errors = array();
// Time
$_SESSION['timezone'] = $timezone;
@date_default_timezone_set($timezone);
DAO_WorkerPref::set($worker->id, 'timezone', $timezone);
// Language
$_SESSION['locale'] = $lang_code;
DevblocksPlatform::setLocale($lang_code);
DAO_WorkerPref::set($worker->id, 'locale', $lang_code);
@($new_password = DevblocksPlatform::importGPC($_REQUEST['change_pass'], 'string'));
@($verify_password = DevblocksPlatform::importGPC($_REQUEST['change_pass_verify'], 'string'));
//[mdf] if nonempty passwords match, update worker's password
if ($new_password != "" && $new_password === $verify_password) {
$session = DevblocksPlatform::getSessionService();
$fields = array(DAO_Worker::PASSWORD => md5($new_password));
DAO_Worker::updateAgent($worker->id, $fields);
}
@($assist_mode = DevblocksPlatform::importGPC($_REQUEST['assist_mode'], 'integer', 0));
DAO_WorkerPref::set($worker->id, 'assist_mode', $assist_mode);
@($keyboard_shortcuts = DevblocksPlatform::importGPC($_REQUEST['keyboard_shortcuts'], 'integer', 0));
DAO_WorkerPref::set($worker->id, 'keyboard_shortcuts', $keyboard_shortcuts);
@($mail_inline_comments = DevblocksPlatform::importGPC($_REQUEST['mail_inline_comments'], 'integer', 0));
DAO_WorkerPref::set($worker->id, 'mail_inline_comments', $mail_inline_comments);
@($mail_always_show_all = DevblocksPlatform::importGPC($_REQUEST['mail_always_show_all'], 'integer', 0));
DAO_WorkerPref::set($worker->id, 'mail_always_show_all', $mail_always_show_all);
// Alternate Email Addresses
@($new_email = DevblocksPlatform::importGPC($_REQUEST['new_email'], 'string', ''));
@($email_delete = DevblocksPlatform::importGPC($_REQUEST['email_delete'], 'array', array()));
// Confirm deletions are assigned to the current worker
if (!empty($email_delete)) {
foreach ($email_delete as $e) {
if (null != ($worker_address = DAO_AddressToWorker::getByAddress($e)) && $worker_address->worker_id == $worker->id) {
DAO_AddressToWorker::unassign($e);
}
}
}
// Assign a new e-mail address if it's legitimate
if (!empty($new_email)) {
if (null != ($addy = DAO_Address::lookupAddress($new_email, true))) {
if (null == ($assigned = DAO_AddressToWorker::getByAddress($new_email))) {
$this->_sendConfirmationEmail($new_email, $worker);
} else {
$pref_errors[] = vsprintf($translate->_('prefs.address.exists'), $new_email);
}
} else {
$pref_errors[] = vsprintf($translate->_('prefs.address.invalid'), $new_email);
}
}
$tpl->assign('pref_errors', $pref_errors);
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('preferences')));
}
示例11: saveTabGeneralAction
function saveTabGeneralAction()
{
@($timezone = DevblocksPlatform::importGPC($_REQUEST['timezone'], 'string'));
@($lang_code = DevblocksPlatform::importGPC($_REQUEST['lang_code'], 'string', 'en_US'));
$worker = PortSensorApplication::getActiveWorker();
$translate = DevblocksPlatform::getTranslationService();
$tpl = DevblocksPlatform::getTemplateService();
// Time
$_SESSION['timezone'] = $timezone;
@date_default_timezone_set($timezone);
DAO_WorkerPref::set($worker->id, 'timezone', $timezone);
// Language
$_SESSION['locale'] = $lang_code;
DevblocksPlatform::setLocale($lang_code);
DAO_WorkerPref::set($worker->id, 'locale', $lang_code);
@($new_password = DevblocksPlatform::importGPC($_REQUEST['change_pass'], 'string'));
@($verify_password = DevblocksPlatform::importGPC($_REQUEST['change_pass_verify'], 'string'));
//[mdf] if nonempty passwords match, update worker's password
if ($new_password != "" && $new_password === $verify_password) {
$session = DevblocksPlatform::getSessionService();
$fields = array(DAO_Worker::PASS => md5($new_password));
DAO_Worker::update($worker->id, $fields);
}
@($assist_mode = DevblocksPlatform::importGPC($_REQUEST['assist_mode'], 'integer', 0));
DAO_WorkerPref::set($worker->id, 'assist_mode', $assist_mode);
@($keyboard_shortcuts = DevblocksPlatform::importGPC($_REQUEST['keyboard_shortcuts'], 'integer', 0));
DAO_WorkerPref::set($worker->id, 'keyboard_shortcuts', $keyboard_shortcuts);
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('preferences')));
}
示例12: doLoginAction
function doLoginAction()
{
@($login = DevblocksPlatform::importGPC($_POST['login'], 'string', ''));
@($password = DevblocksPlatform::importGPC($_POST['password'], 'string', ''));
$settings = PortSensorSettings::getInstance();
$session = DevblocksPlatform::getSessionService();
if (0 == strcasecmp('admin', $login)) {
$admin_pass = $settings->get(PortSensorSettings::ADMIN_PASSWORD, null);
if (0 == strcmp(md5(md5($password)), $admin_pass)) {
$visit = new PortSensorVisit();
$visit->is_admin = true;
$visit->is_feed = false;
$session->setVisit($visit);
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('home')));
return;
}
// Feed Logins
} elseif (null != ($feed = DAO_Feed::getByGUID($login))) {
if (0 == strcmp($password, $feed->secret_key)) {
$visit = new PortSensorVisit();
$visit->is_admin = false;
$visit->is_feed = $feed;
$session->setVisit($visit);
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('home')));
return;
}
}
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login')));
return;
}
示例13: signoffAction
public function signoffAction()
{
$session = DevblocksPlatform::getSessionService();
$visit = $session->getVisit();
DAO_Worker::logActivity(new Model_Activity(null));
$session->clear();
// DevblocksHttpResponse::
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('iphone', 'login')));
}