set() 공개 메소드

public set ( $key, $value )
예제 #1
0
 /**
  * @param $request
  * @param Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->get('lang')) {
         \Language::set($request->get('lang'));
     }
     app()->setLocale(\Language::current());
     return $next($request);
 }
예제 #2
0
 /**
  * @covers FormHandler\Language::get
  */
 public function testGet()
 {
     //check when nothing is loaded it is empty
     $this->assertEquals('', Language::get(1));
     //load language
     Language::load('en');
     //check if a result comes back
     $this->assertNotEmpty(Language::get(1));
     //set an override
     Language::set(1, 'test');
     //check
     $this->assertEquals('test', Language::get(1));
 }
예제 #3
0
 /**
  * Bounce message to sender.
  *
  * @param   object  $message parsed message structure.
  * @param   array   array(ERROR_CODE, ERROR_STRING) of error to bounce
  * @return  void
  */
 public function bounceMessage($message, $error)
 {
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/bounced_email.tpl.text');
     $tpl->assign(array('error_code' => $error[0], 'error_message' => $error[1], 'date' => $message->date, 'subject' => Mime_Helper::fixEncoding($message->subject), 'from' => Mime_Helper::fixEncoding($message->fromaddress), 'to' => Mime_Helper::fixEncoding($message->toaddress), 'cc' => Mime_Helper::fixEncoding(@$message->ccaddress)));
     $sender_email = Mail_Helper::getEmailAddress($message->fromaddress);
     $usr_id = User::getUserIDByEmail($sender_email);
     // change the current locale
     if ($usr_id) {
         Language::set(User::getLang($usr_id));
     }
     $text_message = $tpl->getTemplateContents();
     // send email (use PEAR's classes)
     $mail = new Mail_Helper();
     $mail->setTextBody($text_message);
     $setup = $mail->getSMTPSettings();
     $mail->send($setup['from'], $sender_email, APP_SHORT_NAME . ': ' . ev_gettext('Postmaster notify: see transcript for details'));
     if ($usr_id) {
         Language::restore();
     }
 }
예제 #4
0
/**
 * Set HTTP headers in preparation for a page response.
 *
 * TODO: Figure out caching
 */
function ariPageHeader()
{
    bootstrap();
}
/**
 * Perform end-of-request tasks.
 *
 * This function sets the page cache if appropriate, and allows modules to
 * react to the closing of the page by calling hook_exit().
 */
function ariPageFooter()
{
}
/**
 * Includes and run functions
 */
include_once "./includes/lang.php";
$language = new Language();
$language->set();
checkDependencies();
startARISession();
setARIRoot();
include_once "./includes/main.conf.php";
include_once "./version.php";
include_once "./includes/crypt.php";
include_once "./includes/login.php";
예제 #5
0
파일: index.php 프로젝트: unpush/partuza
        die("Shindig requires the {$module} extention, see <a href='http://www.php.net/{$module}'>http://www.php.net/{$module}</a> for more info");
    }
}
// Basic library requirements that are always needed
require PartuzaConfig::get('library_root') . "/Image.php";
require PartuzaConfig::get('library_root') . "/Language.php";
require PartuzaConfig::get('library_root') . "/Database.php";
require PartuzaConfig::get('library_root') . "/Dispatcher.php";
require PartuzaConfig::get('library_root') . "/Controller.php";
require PartuzaConfig::get('library_root') . "/Model.php";
require PartuzaConfig::get('library_root') . "/Cache.php";
require PartuzaConfig::get('library_root') . "/CacheStorage.php";
require PartuzaConfig::get('library_root') . "/CacheStorageApc.php";
require PartuzaConfig::get('library_root') . "/CacheStorageFile.php";
require PartuzaConfig::get('library_root') . "/CacheStorageMemcache.php";
require PartuzaConfig::get('controllers_root') . "/base/base.php";
// Files copied from shindig, required to make the security token
require PartuzaConfig::get('library_root') . "/Crypto.php";
require PartuzaConfig::get('library_root') . "/BlobCrypter.php";
require PartuzaConfig::get('library_root') . "/SecurityToken.php";
require PartuzaConfig::get('library_root') . "/BasicBlobCrypter.php";
require PartuzaConfig::get('library_root') . "/BasicSecurityToken.php";
// Initialize envirioment, and start the dispatcher
Language::set(PartuzaConfig::get('language'));
$db = new DB(PartuzaConfig::get('db_host'), PartuzaConfig::get('db_port'), PartuzaConfig::get('db_user'), PartuzaConfig::get('db_passwd'), PartuzaConfig::get('db_database'), false);
$uri = $_SERVER["REQUEST_URI"];
$cache = Cache::createCache(PartuzaConfig::get('data_cache'), 'Partuza');
if (($pos = strpos($_SERVER["REQUEST_URI"], '?')) !== false) {
    $uri = substr($_SERVER["REQUEST_URI"], 0, $pos);
}
new Dispatcher($uri);
예제 #6
0
 public function bootstrap($config = array())
 {
     ob_start('ob_gzhandler');
     try {
         $session = new Session();
     } catch (Exception $ex) {
         echo $ex;
     }
     // Find Controller and Action
     try {
         $controller = DEFAULT_CONTROLLER;
         $action = null;
         $route = str_replace(substr(WWW, 0, -1), '', $_SERVER['SCRIPT_URI']);
         if (!empty($route)) {
             $route_parts = explode('/', substr($route, 1));
             if (!empty($route_parts[0])) {
                 $controller = $route_parts[0];
             }
             if (!empty($route_parts[1])) {
                 $action = $route_parts[1];
             }
             $query = $_SERVER['QUERY_STRING'];
             $query_parts = explode('&', $query);
             foreach ($query_parts as $part) {
                 if (!empty($part)) {
                     $part = urldecode($part);
                     $part_data = explode('=', $part);
                     if (!empty($part_data[1])) {
                         $_GET[$part_data[0]] = $part_data[1];
                     } else {
                         $_GET[$part] = $part;
                     }
                 }
             }
         }
     } catch (Exception $exception) {
         $controller = ERROR_CONTROLLER;
     }
     //echo '<pre>';
     //echo $_SERVER['SCRIPT_URI'] . '<br>';
     //print_r($route_parts);
     //echo $controller.':'.$action;
     //exit;
     // Validate Controller and Action
     if (!file_exists(Controller::path($controller))) {
         $controller = ERROR_CONTROLLER;
     }
     require_once Controller::path($controller);
     $class = Controller::classname($controller);
     if (empty($action)) {
         $action = constant($class . '::DEFAULT_VIEW');
     }
     // Format $_POST
     if (!empty($_POST)) {
         foreach ($_POST as $key => $val) {
             if (!is_array($_POST[$key])) {
                 $_POST[$key] = stripslashes($val);
             } else {
                 foreach ($_POST[$key] as $kkey => $vval) {
                     $_POST[$kkey] = stripslashes($vval);
                 }
             }
         }
     }
     // Set Browser
     $browser = Session::get(Cookie::BROWSER);
     //$browser = Cookie::get( Cookie::BROWSER );
     if (empty($browser)) {
         Session::set(Cookie::BROWSER, _set_browser());
         //Cookie::set( Cookie::BROWSER, _set_browser() );
     }
     // Set Language
     $lang = Session::get(Cookie::LANGUAGE);
     if (empty($lang)) {
         $lang = Cookie::get(Cookie::LANGUAGE);
     }
     if (empty($lang)) {
         Language::set();
     }
     // Omit Selection From Navigation
     if (!in_array(Language::controller($controller, Language::ENGLISH, true), array('language', 'error'))) {
         //echo $controller.':'.$action;
         Session::set(Cookie::CONTROLLER, $controller);
         Session::set(Cookie::ACTION, $action);
         //Cookie::set( Cookie::CONTROLLER, $controller );
         //Cookie::set( Cookie::ACTION, $action );
     }
     // Validate User Access
     if (false === Permission::validateAccess($controller, $action)) {
         $controller = DEFAULT_CONTROLLER;
         $action = '';
         require_once Controller::path($controller);
         $class = Controller::classname($controller);
         $action = constant($class . '::DEFAULT_VIEW');
     }
     //$_SERVER[ 'SERVER_SOFTWARE' ] = 'Blow-Fish 1.1.5';
     //header ( 'X-Powered-By: Blow-Fish 1.1.5', true );
     // Initiate
     call_user_func(array(new $class(), str_replace('-', '', $action)));
     if (SHOW_DEBUG) {
         echo '<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><pre>';
         echo '<br /><br /><br /><b>$_GET</b><br />';
         print_r($_GET);
         echo '<br /><b>$_POST</b><br />';
         print_r($_POST);
         echo '<br /><b>$_COOKIE</b><br />';
         print_r($_COOKIE);
         echo '<br /><b>$_SESSION</b><br />';
         print_r($_SESSION);
         echo '<br /><b>$_SERVER</b><br />';
         print_r($_SERVER);
     }
     ob_end_flush();
 }
예제 #7
0
 public function en()
 {
     Language::set(Language::ENGLISH);
     header('Location: /' . Language::controller(Session::get(Cookie::CONTROLLER), Language::ENGLISH, true) . '/' . Language::action(Session::get(Cookie::ACTION), Language::ENGLISH, true), 302);
     exit;
 }
예제 #8
0
 /**
  * Method used to send the account details of an user.
  *
  * @param   integer $usr_id The user ID
  * @return  void
  */
 public function notifyAccountDetails($usr_id)
 {
     $info = User::getDetails($usr_id);
     $info['projects'] = Project::getAssocList($usr_id, true, true);
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/account_details.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'user' => $info));
     Language::set(User::getLang($usr_id));
     $text_message = $tpl->getTemplateContents();
     // send email (use PEAR's classes)
     $mail = new Mail_Helper();
     $mail->setTextBody($text_message);
     $setup = $mail->getSMTPSettings();
     $to = $mail->getFormattedName($info['usr_full_name'], $info['usr_email']);
     // TRANSLATORS: %s = APP_SHORT_NAME
     $subject = ev_gettext('%s: Your User Account Details', APP_SHORT_NAME);
     $mail->send($setup['from'], $to, $subject);
     Language::restore();
 }
예제 #9
0
 public function fr()
 {
     Language::set(Language::FRENCH);
     header('Location: /' . Language::controller(Session::get(Cookie::CONTROLLER), Language::FRENCH) . '/' . Language::action(Session::get(Cookie::ACTION), Language::FRENCH), 302);
     exit;
 }
예제 #10
0
 /**
  * @brief init LogX 全局初始化方法
  *
  * @return void
  */
 public static function init()
 {
     // 输出 Logo
     if (isset($_GET['591E-D5FC-8065-CD36-D3E8-E45C-DB86-9197'])) {
         Response::logo();
     }
     // 非 DEBUG 模式下关闭错误输出
     if (defined('LOGX_DEBUG')) {
         error_reporting(E_ALL);
     } else {
         error_reporting(0);
     }
     // 设置自动载入函数
     function __autoLoad($className)
     {
         if (substr($className, -7) == 'Library' && is_file(LOGX_LIB . $className . '.php')) {
             @(require_once LOGX_LIB . $className . '.php');
         }
     }
     // 设置错误与异常处理函数
     set_error_handler(array(__CLASS__, 'error'));
     set_exception_handler(array(__CLASS__, 'exception'));
     // 运行环境检查
     if (!version_compare(PHP_VERSION, '5.0.0', '>=')) {
         throw new LogXException(sprintf(_t('LogX needs PHP 5.0.x or higher to run. You are currently running PHP %s.'), PHP_VERSION));
     }
     if (!version_compare(PHP_VERSION, '5.2.0', '>=')) {
         // 针对低版本 PHP 的兼容代码
         @(require_once LOGX_CORE . 'Compat.php');
     }
     // 设置语言
     if (defined('LOGX_LANGUAGE')) {
         Language::set(LOGX_LANGUAGE);
     } else {
         Language::set('zh-cn');
     }
     // 预编译核心文件
     global $coreFiles;
     if (!defined('LOGX_DEBUG') && !file_exists(LOGX_CACHE . '~core.php')) {
         Compile::build(LOGX_CACHE, $coreFiles, 'core');
     } elseif (!defined('LOGX_DEBUG')) {
         $file_time = filemtime(LOGX_CACHE . '~core.php');
         foreach ($coreFiles as $file) {
             if (filemtime($file) > $file_time) {
                 Compile::build(LOGX_CACHE, $coreFiles, 'core');
                 break;
             }
         }
     }
     self::$_globalVars = array('RUN' => array('TIME' => microtime(TRUE), 'MEM' => function_exists('memory_get_usage') ? memory_get_usage() : 0, 'LANG' => 'zh-cn'), 'SYSTEM' => array('OS' => PHP_OS, 'HTTP' => Request::S('SERVER_SOFTWARE', 'string'), 'PHP' => PHP_VERSION, 'MYSQL' => ''), 'SUPPORT' => array('MYSQL' => function_exists('mysql_connect'), 'GD' => function_exists('imagecreate'), 'MEMCACHE' => function_exists('memcache_connect'), 'SHMOP' => function_exists('shmop_open'), 'GZIP' => function_exists('ob_gzhandler'), 'TIMEZONE' => function_exists('date_default_timezone_set'), 'AUTOLOAD' => function_exists('spl_autoload_register')), 'INI' => array('ALLOW_CALL_TIME_PASS_REFERENCE' => ini_get('allow_call_time_pass_reference'), 'MAGIC_QUOTES_GPC' => ini_get('magic_quotes_gpc'), 'REGISTER_GLOBALS' => ini_get('register_globals'), 'ALLOW_URL_FOPEN' => ini_get('allow_url_fopen'), 'ALLOW_URL_INCLUDE' => ini_get('allow_url_include'), 'SAFE_MODE' => ini_get('safe_mode'), 'MAX_EXECUTION_TIME' => ini_get('max_execution_time'), 'MEMORY_LIMIT' => ini_get('memory_limit'), 'POST_MAX_SIZE' => ini_get('post_max_size'), 'FILE_UPLOADS' => ini_get('file_uploads'), 'UPLOAD_MAX_FILESIZE' => ini_get('upload_max_filesize'), 'MAX_FILE_UPLOADS' => ini_get('max_file_uploads')));
     // 清除不需要的变量,防止变量注入
     $defined_vars = get_defined_vars();
     foreach ($defined_vars as $key => $value) {
         if (!in_array($key, array('_POST', '_GET', '_COOKIE', '_SERVER', '_FILES'))) {
             ${$key} = '';
             unset(${$key});
         }
     }
     // 对用户输入进行转义处理
     if (!get_magic_quotes_gpc()) {
         $_GET = self::addSlashes($_GET);
         $_POST = self::addSlashes($_POST);
         $_COOKIE = self::addSlashes($_COOKIE);
     }
     // 开启输出缓存
     if (defined('LOGX_GZIP') && self::$_globalVars['SUPPORT']['GZIP']) {
         ob_start('ob_gzhandler');
     } else {
         ob_start();
     }
     // 连接到数据库
     Database::connect(DB_HOST, DB_USER, DB_PWD, DB_NAME, DB_PCONNECT);
     self::$_globalVars['SYSTEM']['MYSQL'] = Database::version();
     // 设定时区
     if (self::$_globalVars['SUPPORT']['TIMEZONE']) {
         date_default_timezone_set(OptionLibrary::get('timezone'));
     }
     // 连接到缓存
     Cache::connect(CACHE_TYPE);
     // 初始化路由表
     Router::init();
     // 初始化主题控制器
     Theme::init();
     // 初始化 Plugin
     Plugin::initPlugins();
     // 初始化全局组件
     Widget::initWidget('Global');
     Widget::initWidget('Widget');
     Widget::initWidget('Page');
     Widget::initWidget('User');
     // 尝试自动登录
     Widget::getWidget('User')->autoLogin();
     // 启动路由分发
     Router::dispatch();
 }