예제 #1
0
파일: CCLang.php 프로젝트: clancats/core
 /**
  * CCLang::alias tests
  */
 public function test_alias()
 {
     CCLang::set_current('en');
     CCLang::alias(':test', 'CCUnit::phpunit');
     $this->assertEquals('Welcome', __(':test.welcome'));
     $this->assertEquals('Hello John', __(':test.hello', array('name' => 'John')));
 }
예제 #2
0
파일: Instance.php 프로젝트: clancats/core
 /**
  * get the client data
  *
  * @param string		$key
  * @return mixed
  */
 public function client($key = null)
 {
     // check if we already set the client object
     if (is_null($this->client)) {
         // make client
         $this->client = new \stdClass();
         /*
          * get clients ip address
          */
         // Cloudlfare fix
         if ($this->has_server('HTTP_CF_CONNECTING_IP')) {
             $this->client->ip = $this->server('HTTP_CF_CONNECTING_IP');
         } elseif ($this->has_server('HTTP_X_FORWARDED_FOR')) {
             $this->client->ip = $this->server('HTTP_X_FORWARDED_FOR');
         } elseif ($this->has_server('HTTP_CLIENT_IP')) {
             $this->client->ip = $this->server('HTTP_CLIENT_IP');
         } else {
             $this->client->ip = $this->server('REMOTE_ADDR', '127.0.0.1');
         }
         /*
          * set clients user agent
          */
         $this->client->agent = $this->server('HTTP_USER_AGENT', '');
         /*
          * set clients port
          */
         $this->client->port = $this->server('REMOTE_PORT', '');
         /*
          * set clients fingerprint based on host and agent
          */
         $this->client->fingerprint = CCStr::hash($this->client('agent') . $this->client('ip'));
         /*
          * set clients language
          */
         $this->client->language = CCLang::set_current($this->server('HTTP_ACCEPT_LANGUAGE'));
     }
     // return the object
     if (is_null($key)) {
         return $this->client;
     }
     // return a special key
     return $this->client->{$key};
 }