示例#1
0
 public static function getLanguage()
 {
     if (self::$LANG == NULL) {
         include 'config/en.php';
         self::$LANG = new LanguageStore($langArray);
     }
     return self::$LANG;
 }
 /**
  * startSession 
  * 
  * @param mixed $context     SessionContext 
  * @param mixed $useExisting Whether to use existing session.
  *
  * @access public
  * @return void
  */
 public function startSession($context = null, $useExisting = false)
 {
     $logger = $GLOBALS['logger'];
     $app = $GLOBALS['app'];
     // Strip '.'
     $appContext = rtrim($app->getConfiguration()->getApplicationContext(), '.');
     if (empty($appContext)) {
         $appContext = "/";
     } else {
         $appContext = "/" . $appContext . "/";
     }
     if ($useExisting === true) {
         $sessionCookieName = $app->getConfiguration()->getApplicationContext() . "-" . "_n5_session";
         $sessionCookieName = preg_replace("/\\./", "_", $sessionCookieName);
         session_set_cookie_params(0, $appContext, null, false, true);
         session_name($sessionCookieName);
         session_start();
         if (!$this->isActiveSession()) {
             self::resetActiveSession();
         }
         $this->_session = new Session($_SESSION);
         if ($this->_session->getAttribute('category') !== null) {
             return;
         }
     }
     if (!isset($_SESSION[self::GLOBAL_PREFIX . 'category'])) {
         // No session exists yet.
         if ($context === null) {
             $context = new WebContext($_REQUEST);
         }
         session_unset();
         session_destroy();
         $sessionCookieName = $app->getConfiguration()->getApplicationContext() . "-" . "_n5_session";
         $sessionCookieName = preg_replace("/\\./", "_", $sessionCookieName);
         session_set_cookie_params(0, $appContext, null, false, true);
         session_name($sessionCookieName);
         session_start();
         session_regenerate_id();
         $_SESSION = array();
         $app = $GLOBALS['app'];
         if (!$app->getConfiguration()->isLocal()) {
             //$handler = new CachedSessionHandler();
             //session_set_save_handler(
             //array($handler, 'open'),
             //array($handler, 'close'),
             //array($handler, 'read'),
             //array($handler, 'write'),
             //array($handler, 'destroy'),
             //array($handler, 'gc')
             //);
         }
         $_SESSION[self::GLOBAL_PREFIX . 'category'] = $context->get('device');
         $_SESSION[self::GLOBAL_PREFIX . 'location'] = $context->get('location');
         $_SESSION[self::GLOBAL_PREFIX . 'last_accessed'] = time();
     }
     //end if
     $this->_session = new Session($_SESSION);
 }
    /**
     * Notify about the fault
     *
     * @param string $email address to be notified about the fault
     * @param Exception $e uncaught exception that caused application fault
     * @return void
     */
    protected function notify500($email, Exception $e)
    {
        //
        // TODO log this
        //
        $request = $this->webContext->getRequest();
        $message = <<<EOT
Crash at {$request->getHttpUrl()->getHost()}:
{$e->getMessage()}

The request: {$request->getHttpUrl()}
Request method: {$request->getRequestMethod()}

{$e->getTraceAsString()}
EOT;
        mail($email, PHOEBIUS_SHORT_PRODUCT_NAME . "crash at {$request->getHttpUrl()->getHost()} (" . get_class($e) . ")", $message);
    }
 /**
  * startSession 
  * 
  * @param mixed $context     SessionContext 
  * @param mixed $useExisting Whether to use existing session.
  *
  * @access public
  * @return void
  */
 public function startSession($context = null, $useExisting = false)
 {
     $logger = $GLOBALS['logger'];
     if ($useExisting === true) {
         session_name('_n5_session');
         session_start();
         $this->_session = new Session($_SESSION);
         if ($this->_session->getAttribute('category') !== null) {
             return;
         }
     }
     if (!isset($_SESSION[self::GLOBAL_PREFIX . 'category'])) {
         // No session exists yet.
         if ($context === null) {
             $context = new WebContext($_REQUEST);
         }
         session_unset();
         session_destroy();
         session_set_cookie_params(0, '/', '', false, true);
         session_name('_n5_session');
         session_start();
         session_regenerate_id();
         $_SESSION = array();
         $app = $GLOBALS['app'];
         if (!$app->getConfiguration()->isLocal()) {
             //$handler = new CachedSessionHandler();
             //session_set_save_handler(
             //array($handler, 'open'),
             //array($handler, 'close'),
             //array($handler, 'read'),
             //array($handler, 'write'),
             //array($handler, 'destroy'),
             //array($handler, 'gc')
             //);
         }
         $_SESSION[self::GLOBAL_PREFIX . 'category'] = $context->get('device');
         $_SESSION[self::GLOBAL_PREFIX . 'location'] = $context->get('location');
         $_SESSION[self::GLOBAL_PREFIX . 'last_accessed'] = time();
     }
     //end if
     $this->_session = new Session($_SESSION);
 }
 /**
  * (non-PHPdoc)
  * @see Controller::run()
  */
 public function runImpl()
 {
     $this->page = $this->getPage();
     // check access control
     // get page access object if one defined.
     // check access
     $access = WebContext::getPageAccess($this->page);
     if ($access != NULL && $this->isAuthenticated() && !$access->hasPageAccess($this->getUser())) {
         include 'config/includes/pages/403.php';
     } else {
         // requires auth and is logged in ?
         if ($this->isAuthenticatedPage() && !$this->isAuthenticated()) {
             $this->redirectToLogin();
         }
         $this->loadProcessor();
         $this->loadForms();
         $this->loadPage();
         // displays the resultant page using the desired page template (templates/default.php if not set)
         include 'config/templates/' . Response::getInstance()->getPageTemplate($this->getUser());
     }
 }
示例#6
0
                     if ($member->getDisplaySettings()->hasLabel('CALENDAR_TITLE')) {
                         $titleField = $member->getName();
                     }
                 }
             }
         }
     }
 }
 $reqDao = $table . "Dao";
 $dao = new $reqDao();
 $objs = $dao->getAll();
 if (!is_null($objs) && $objs != -1) {
     foreach ($objs as $obj) {
         $titleMethod = 'get' . $titleField;
         $startMethod = 'get' . $startField;
         $tempEntry = array('id' => $obj->getPk(), 'title' => $obj->{$titleMethod}(), 'start' => $obj->{$startMethod}(), 'url' => Tabs::viewInNewTabJs('Update', $table, $obj->getPk(), WebContext::getLanguage()->get($table) . ' ' . $obj->getPk()));
         if ($endField != NULL) {
             $endMethod = 'get' . $endField;
             $tempEntry['end'] = $obj->{$endMethod}();
         }
         $tempClassName = 'cal-' . $def->getTable()->name;
         if ($completeField != NULL) {
             $completeMethod = 'get' . $completeField();
             if ($obj->{$completeMethod}()) {
                 $tempClassName .= ' jack-cal-complete';
                 $tempEntry['title'] = 'COMPLETE:' . $tempEntry['title'];
             } else {
                 $tempClassName .= ' jack-cal-incomplete';
                 $tempEntry['title'] = 'PENDING: ' . $tempEntry['title'];
             }
         }
示例#7
0
<?php

try {
    require_once 'config/settings.php';
    $controller = WebContext::getController(BaseController::getPage());
    $controller->run();
} catch (Exception $e) {
    mail(StaticConfig::getAdministratorEmail(), "{$site_name} - Site error", $e);
    header('Location: /error');
    die;
}
示例#8
0
文件: home.php 项目: ryanhend/Inform8
<?php

/* Copyright 2011 - 88 Creative Pty Ltd. 
 * Copyright of this program is the property of 88 Creative, 
 * without whose written permission reproduction in
 * whole or in part is prohibited. All rights reserved.
 * http://www.inform8.com
 * http://www.88creative.com.au
 */
echo WebContext::getLanguage()->get('welcome') . " " . Session::getInstance()->getAuthenticationManager()->getUser()->getFirstName();
?>

示例#9
0
if ($action == null) {
    // old option, conflicts with the file upload plugin though... form
    // action attribute does not get set...
    $action = Request::getSafeGetOrPost("action");
}
if ($action == 'help') {
    include 'config/authenticatedajax/help.php';
} else {
    if ($action == 'home') {
        include 'config/authenticatedajax/home.php';
    } else {
        if ($action == 'calendar') {
            include 'config/authenticatedajax/calendar.php';
        } else {
            if ($action == 'Manager' || $action == 'Update' || $action == 'View' || $action == 'Create' || $action == 'Order' || $action == 'FkData' || $action == 'Upload' || $action == 'Send') {
                require 'config/authenticatedajax/' . $reqobj . $action . '.php';
            } else {
                require 'config/authenticatedajax/' . $reqobj . 'Crud' . '.php';
                $crudName = $reqobj . 'Crud';
                $crud = new $crudName(WebContext::getLanguage());
                $res = $crud->{$action}();
                $wrapWithTa = Request::getSafeGetOrPost("wta");
                if ($wrapWithTa == 1) {
                    echo '<textarea>' . json_encode($res) . '</textarea>';
                } else {
                    echo json_encode($res);
                }
            }
        }
    }
}
示例#10
0
<?php

ini_set('include_path', './includes/');
require_once "version.inc";
require_once "context.inc";
require_once "webcontext.inc";
if (isset($_GET['context'])) {
    $contextfile = "./context/" . $_GET['context'] . ".context";
    if (!file_exists($contextfile)) {
        print "ERROR: context \"" . $_GET['context'] . "\" could not be found.";
        exit(1);
    }
    $s = implode("", @file($contextfile));
    $context = unserialize($s);
    if ($context->version != $version) {
        print "ERROR: context is version " . $context->version . ", while the app needs version " . $version . ".";
        exit(1);
    }
    $webcontext = new WebContext($context);
    $webcontext->start();
} else {
    print "ERROR: script has to be called with the option \"context\".";
    exit(1);
}
示例#11
0
ini_set('include_path', ini_get('include_path') . ':plugins/phpexcel/');
/** PHPExcel */
include 'PHPExcel.php';
/** PHPExcel_Writer_Excel2007 */
include 'PHPExcel/Writer/Excel5.php';
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
// Set properties
$objPHPExcel->getProperties()->setCreator("");
$objPHPExcel->getProperties()->setLastModifiedBy("");
$objPHPExcel->getProperties()->setTitle("");
$objPHPExcel->getProperties()->setSubject("");
$objPHPExcel->getProperties()->setDescription("");
// Add some data
$objPHPExcel->setActiveSheetIndex(0);
if ($expanded == '1') {
    $builder->generateExpandedHeader(1, 0, $objPHPExcel, WebContext::getLanguage());
} else {
    $builder->generateHeader(1, $objPHPExcel, WebContext::getLanguage());
}
for ($i = 0; $i < $objCount; $i++) {
    if ($expanded == '1') {
        $builder->generateExpandedRow($objs[$i], $i + 2, 0, $objPHPExcel);
    } else {
        $builder->generateRow($objs[$i], $i + 2, $objPHPExcel);
    }
}
// Rename sheet
$objPHPExcel->getActiveSheet()->setTitle($reqobj);
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save('php://output');