Esempio n. 1
0
 /**
  * read the session
  *
  * @access public
  * @param
  *        	boolean, set to true if we want to force a new session to be created
  * @return Fuel\Core\Session_Driver
  */
 public function read($force = false)
 {
     // initialize the session
     $this->data = array();
     $this->keys = array();
     $this->flash = array();
     // get the session cookie
     $payload = $this->_get_cookie();
     // validate it
     if ($payload === false or $force) {
         // not a valid cookie, or a forced session reset
     } elseif (!isset($payload[0]) or !is_array($payload[0])) {
         // not a valid cookie payload
     } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) {
         // session has expired
     } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) {
         // IP address doesn't match
     } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) {
         // user agent doesn't match
     } else {
         // session is valid, retrieve the payload
         if (isset($payload[0]) and is_array($payload[0])) {
             $this->keys = $payload[0];
         }
         if (isset($payload[1]) and is_array($payload[1])) {
             $this->data = $payload[1];
         }
         if (isset($payload[2]) and is_array($payload[2])) {
             $this->flash = $payload[2];
         }
     }
     return parent::read();
 }
Esempio n. 2
0
 /**
  * read the session
  *
  * @access	public
  * @param	boolean, set to true if we want to force a new session to be created
  * @return	Fuel\Core\Session_Driver
  */
 public function read($force = false)
 {
     // initialize the session
     $this->data = array();
     $this->keys = array();
     $this->flash = array();
     // get the session cookie
     $payload = $this->_get_cookie();
     // validate it
     if ($force) {
         // a forced session reset
     } elseif ($payload === false) {
         // no cookie found
     } elseif (!isset($payload[0]) or !is_array($payload[0])) {
         logger('DEBUG', 'Error: not a valid cookie payload!');
     } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) {
         logger('DEBUG', 'Error: session id has expired!');
     } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) {
         logger('DEBUG', 'Error: IP address in the session doesn\'t match this requests source IP!');
     } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) {
         logger('DEBUG', 'Error: User agent in the session doesn\'t match the browsers user agent string!');
     } else {
         // session is valid, retrieve the payload
         if (isset($payload[0]) and is_array($payload[0])) {
             $this->keys = $payload[0];
         }
         if (isset($payload[1]) and is_array($payload[1])) {
             $this->data = $payload[1];
         }
         if (isset($payload[2]) and is_array($payload[2])) {
             $this->flash = $payload[2];
         }
     }
     return parent::read();
 }
Esempio n. 3
0
 public static function check_legacy_ie($criteria_version = 8)
 {
     if (!$criteria_version) {
         return false;
     }
     if (!preg_match('/MSIE\\s([\\d.]+)/i', \Input::user_agent(), $matches)) {
         return false;
     }
     $version = floor($matches[1]);
     return $version <= $criteria_version;
 }
 /**
  * create a new session
  *
  * @access	public
  * @return	Fuel\Core\Session_Cookie
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['ip_hash'] = md5(\Input::ip() . \Input::real_ip());
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     $this->keys['payload'] = '';
     return $this;
 }
 /**
  * create a new session
  *
  * @access	public
  * @return	Fuel\Core\Session_Memcached
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['previous_id'] = $this->keys['session_id'];
     // prevents errors if previous_id has a unique index
     $this->keys['ip_hash'] = md5(\Input::ip() . \Input::real_ip());
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     return $this;
 }
Esempio n. 6
0
 /**
  * create a new session
  *
  * @access	public
  * @return	void
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['ip_address'] = \Input::real_ip();
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     $this->keys['payload'] = '';
     // and set the session cookie
     $this->_set_cookie();
 }
Esempio n. 7
0
 public function action_send()
 {
     // CSRF対策
     if (!Security::check_token()) {
         throw new HttpInvalidInputException('ページ遷移が正しくありません');
     }
     $form = $this->forge_form();
     $val = $form->validation()->add_callable('MyValidationRules');
     if (!$val->run()) {
         $form->repopulate();
         $this->template->title = 'コンタクトフォーム: エラー';
         $this->template->content = View::forge('form/index');
         $this->template->content->set_safe('html_error', $val->show_errors());
         $this->template->content->set_safe('html_form', $form->build('form/confirm'));
         return;
     }
     $post = $val->validated();
     $post['ip_address'] = Input::ip();
     $post['user_agent'] = Input::user_agent();
     unset($post['submit']);
     // データベースへ保存
     $model_form = Model_Form::forge($post);
     $ret = $model_form->save();
     if (!$ret) {
         Log::error('データベース保存エラー', __METHOD__);
         $form->repopulate();
         $this->template->title = 'コンタクトフォーム: サーバエラー';
         $this->template->content = View::forge('form/index');
         $html_error = '<p>サーバでエラーが発生しました。</p>';
         $this->template->content->set_safe('html_error', $html_error);
         $this->template->content->set_safe('html_form', $form->build('form/confirm'));
         return;
     }
     // メールの送信
     try {
         $mail = new Model_Mail();
         $mail->send($post);
         $this->template->title = 'コンタクトフォーム: 送信完了';
         $this->template->content = View::forge('form/send');
         return;
     } catch (EmailValidationFailedException $e) {
         Log::error('メール検証エラー: ' . $e->getMessage(), __METHOD__);
         $html_error = '<p>メールアドレスに誤りがあります。</p>';
     } catch (EmailSendingFailedException $e) {
         Log::error('メール送信エラー: ' . $e->getMessage(), __METHOD__);
         $html_error = '<p>メールを送信できませんでした。</p>';
     }
     $form->repopulate();
     $this->template->title = 'コンタクトフォーム: 送信エラー';
     $this->template->content = View::forge('form/index');
     $this->template->content->set_safe('html_error', $html_error);
     $this->template->content->set_safe('html_form', $form->build('form/confirm'));
 }
 public function response()
 {
     $error_code = $this->getMessage();
     $error_list = Lang::load('error/user', $error_code);
     if (!isset($error_list[$error_code])) {
         $error_code = \Model_Error::ER00001;
     }
     $error_message = $error_list[$error_code];
     $params = array('error_code' => $error_code, 'error_message' => $error_message, 'line' => $this->getLine(), 'file' => $this->getFile(), 'url' => Uri::main(), 'input' => print_r(Input::all(), true), 'real_ip' => Input::real_ip(), 'user_agent' => Input::user_agent(), 'user_id' => Auth::get_user_id(), 'occurred_at' => date('Y/m/d H:i:s'));
     $email = new Model_Email();
     $email->sendMailByParams('error', $params);
     $response = \Request::forge('errors/index', false)->execute($params)->response();
     return $response;
 }
Esempio n. 9
0
 public static function end()
 {
     // cookie details
     $name = Config::get('session.name', 'anchorcms');
     $expire = time() + Config::get('session.expire', 86400);
     $path = Config::get('session.path', '/');
     $domain = Config::get('session.domain', '');
     // update db session
     Db::update('sessions', array('date' => date(DATE_ISO8601), 'ip' => Input::ip_address(), 'ua' => Input::user_agent(), 'data' => serialize(static::$data)), array('id' => static::$id));
     // create cookie with ID
     if (!Cookie::write($name, static::$id, $expire, $path, $domain)) {
         Log::error('Could not write session cookie: ' . static::$id);
     }
 }
Esempio n. 10
0
 /**
  * create a new session
  *
  * @access	public
  * @return	void
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['previous_id'] = $this->keys['session_id'];
     // prevents errors if previous_id has a unique index
     $this->keys['ip_hash'] = md5(\Input::ip() . \Input::real_ip());
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     // create the session record
     $this->_write_redis($this->keys['session_id'], serialize(array()));
     // and set the session cookie
     $this->_set_cookie();
 }
Esempio n. 11
0
 /**
  * create a new session
  *
  * @access	public
  * @return	void
  */
 public function create()
 {
     // create a new session
     $this->keys['session_id'] = $this->_new_session_id();
     $this->keys['previous_id'] = $this->keys['session_id'];
     // prevents errors if previous_id has a unique index
     $this->keys['ip_hash'] = md5(\Input::ip() . \Input::real_ip());
     $this->keys['user_agent'] = \Input::user_agent();
     $this->keys['created'] = $this->time->get_timestamp();
     $this->keys['updated'] = $this->keys['created'];
     $this->keys['payload'] = '';
     // create the session record
     $result = \DB::insert($this->config['table'], array_keys($this->keys))->values($this->keys)->execute($this->config['database']);
     // and set the session cookie
     $this->_set_cookie();
 }
Esempio n. 12
0
 public function before()
 {
     parent::before();
     $client_type = false;
     $ua = \Input::user_agent();
     if (preg_match('/MicroMessenger/i', $ua)) {
         //加载微信公众号信息
         $this->load_wx_account();
         //加载微信粉丝OPENID信息
         $this->load_wechat();
         $client_type = 'wechat';
     }
     $this->load_seller();
     $this->getToken();
     \View::set_global(['client_type' => $client_type]);
 }
Esempio n. 13
0
    public function build_mail($post)
    {
        $data['from'] = $post['email'];
        $data['from_name'] = $post['name'];
        $data['to'] = '*****@*****.**';
        $data['to_name'] = '管理者';
        $data['subject'] = 'コンタクトフォーム';
        $ip = Input::ip();
        $agent = Input::user_agent();
        $data['body'] = <<<END
------------------------------------------------------------
          名前: {$post['name']}
メールアドレス: {$post['email']}
    IPアドレス: {$ip}
      ブラウザ: {$agent}
------------------------------------------------------------
コメント:
{$post['comment']}
------------------------------------------------------------
END;
        return $data;
    }
Esempio n. 14
0
    protected function build_mail($post)
    {
        Config::load('contact_form', true);
        $data['from'] = $post['email'];
        $data['from_name'] = $post['name'];
        $data['to'] = Config::get('contact_form.admin_email');
        $data['to_name'] = Config::get('contact_form.admin_name');
        $data['subject'] = Config::get('contact_form.subject');
        $ip = Input::ip();
        $agent = Input::user_agent();
        $data['body'] = <<<END
------------------------------------------------------------
          名前: {$post['name']}
メールアドレス: {$post['email']}
    IPアドレス: {$ip}
      ブラウザ: {$agent}
------------------------------------------------------------
コメント:
{$post['comment']}
------------------------------------------------------------
END;
        return $data;
    }
Esempio n. 15
0
 /**
  * Generate the default data for the context object.
  * 
  * @param bool $js	Set this to generate the context for JS
  *  
  * @return array The array to use for the "context" object
  */
 private function _get_context($js = true)
 {
     $context_data = array('context' => array('locale' => $this->_get_locale(), 'timezone' => date('e')));
     if ($js !== true) {
         $php_context = array('ip' => \Input::real_ip(), 'userAgent' => \Input::user_agent());
         $context_data['context'] = \Arr::merge($context_data['context'], $php_context);
         // Don't use \Arr::set() since that will always add the keys.
         $context['campaign'] = $this->_add_element('name', \Input::get('utm_campaign'), array());
         $context['campaign'] = $this->_add_element('source', \Input::get('utm_source'), $context['campaign']);
         $context['campaign'] = $this->_add_element('medium', \Input::get('utm_medium'), $context['campaign']);
         $context['campaign'] = $this->_add_element('term', \Input::get('utm_term'), $context['campaign']);
         $context['campaign'] = $this->_add_element('content', \Input::get('utm_content'), $context['campaign']);
         if (!empty($context['campaign'])) {
             $context_data['context'] = \Arr::merge($context_data['context'], $context);
         }
         // If we're using Google Analytics, we add it's ID.
         if (!empty($this->_ga_cookie_id)) {
             \Arr::set($context_data, 'integrations.Google Analytics.clientId', $this->_ga_cookie_id);
         }
     }
     return $context_data;
 }
Esempio n. 16
0
File: app.php Progetto: ratiw/petro
 public function action_login()
 {
     if (Input::method() == 'POST') {
         if (!\Security::check_token()) {
             \Log::info('CSRF detected from IP:' . \Input::ip() . ', Real IP:' . \Input::real_ip() . ', Ref:' . \Input::referrer() . ', Agent:' . \Input::user_agent());
             throw new \HttpNotFoundException();
         }
         $val = \Validation::forge('users');
         $val->add_field('username', 'Your username', 'required|min_length[3]|max_length[20]');
         $val->add_field('password', 'Your password', 'required|min_length[3]|max_length[20]');
         if ($val->run()) {
             $valid_login = \Auth::instance()->login($val->validated('username'), $val->validated('password'));
             if ($valid_login) {
                 $user = \Auth::instance()->get_user_info();
                 \Session::set('user_info', $user);
                 \Session::set_flash('success', 'Welcome, ' . $val->validated('username'));
                 $url = \Session::get('redirect_url', '/');
                 \Session::delete('redirect_url');
                 \Response::redirect($url);
             } else {
                 $data['username'] = $val->validated('username');
                 \Session::set_flash('error', 'Wrong username/password. Try again');
             }
         } else {
             \Session::set_flash('error', 'Please correct the error(s).');
             $this->template->set_global('errors', $val->error());
         }
     }
     $this->template->title = 'Login';
     $this->template->page_title = 'Login';
     $this->template->content = \View::forge('petro/login');
 }
Esempio n. 17
0
 /**
  * read the session
  *
  * @access	public
  * @param	boolean, set to true if we want to force a new session to be created
  * @return	Fuel\Core\Session_Driver
  */
 public function read($force = false)
 {
     // initialize the session
     $this->data = array();
     $this->keys = array();
     $this->flash = array();
     // get the session cookie
     $cookie = $this->_get_cookie();
     // if a cookie was present, find the session record
     if ($cookie and !$force and isset($cookie[0])) {
         // read the session file
         $payload = $this->_read_redis($cookie[0]);
         if ($payload === false) {
             // cookie present, but session record missing. force creation of a new session
             return $this->read(true);
         }
         // unpack the payload
         $payload = $this->_unserialize($payload);
         // session referral?
         if (isset($payload['rotated_session_id'])) {
             $payload = $this->_read_redis($payload['rotated_session_id']);
             if ($payload === false) {
                 // cookie present, but session record missing. force creation of a new session
                 return $this->read(true);
             }
             // unpack the payload
             $payload = $this->_unserialize($payload);
         }
         if (!isset($payload[0]) or !is_array($payload[0])) {
             // not a valid cookie payload
         } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) {
             // session has expired
         } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) {
             // IP address doesn't match
         } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) {
             // user agent doesn't match
         } else {
             // session is valid, retrieve the rest of the payload
             if (isset($payload[0]) and is_array($payload[0])) {
                 $this->keys = $payload[0];
             }
             if (isset($payload[1]) and is_array($payload[1])) {
                 $this->data = $payload[1];
             }
             if (isset($payload[2]) and is_array($payload[2])) {
                 $this->flash = $payload[2];
             }
         }
     }
     return parent::read();
 }
Esempio n. 18
0
 /**
  * record login
  * @param integer $account_id
  * @param integer $attempt 0 for failed, 1 for success
  * @param string $attempt_text attempt text
  * @return boolean
  */
 public function recordLogin($account_id = '', $attempt = '0', $attempt_text = '')
 {
     if (!is_numeric($account_id) || !is_numeric($attempt)) {
         return false;
     }
     if ($attempt_text == null) {
         $attempt_text = null;
     }
     $site_id = \Model_Sites::getSiteId(false);
     // get browser class for use instead of fuelphp agent which is does not work.
     include_once APPPATH . 'vendor' . DS . 'browser' . DS . 'lib' . DS . 'Browser.php';
     $browser = new Browser();
     // set data for insertion
     $data['account_id'] = $account_id;
     $data['site_id'] = $site_id;
     $data['login_ua'] = \Input::user_agent();
     $data['login_os'] = $browser->getPlatform();
     $data['login_browser'] = $browser->getBrowser() . ' ' . $browser->getVersion();
     $data['login_ip'] = \Input::real_ip();
     $data['login_time'] = time();
     $data['login_time_gmt'] = \Extension\Date::localToGmt();
     $data['login_attempt'] = $attempt;
     $data['login_attempt_text'] = $attempt_text;
     \DB::insert(static::$_table_name)->set($data)->execute();
     unset($browser, $data, $site_id);
     return true;
 }
Esempio n. 19
0
 /**
  * read the session
  *
  * @access	public
  * @param	boolean, set to true if we want to force a new session to be created
  * @return	Fuel\Core\Session_Driver
  */
 public function read($force = false)
 {
     // initialize the session
     $this->data = array();
     $this->keys = array();
     $this->flash = array();
     $this->record = null;
     // get the session cookie
     $cookie = $this->_get_cookie();
     // if a cookie was present, find the session record
     if ($cookie and !$force and isset($cookie[0])) {
         // read the session record
         $this->record = \DB::select()->where('session_id', '=', $cookie[0])->from($this->config['table'])->execute($this->config['database']);
         // record found?
         if ($this->record->count()) {
             $payload = $this->_unserialize($this->record->get('payload'));
         } else {
             // try to find the session on previous id
             $this->record = \DB::select()->where('previous_id', '=', $cookie[0])->from($this->config['table'])->execute($this->config['database']);
             // record found?
             if ($this->record->count()) {
                 $payload = $this->_unserialize($this->record->get('payload'));
             } else {
                 // cookie present, but session record missing. force creation of a new session
                 logger('DEBUG', 'Error: Session cookie with ID "' . $cookie[0] . '" present but corresponding record is missing');
                 return $this->read(true);
             }
         }
         if (!isset($payload[0]) or !is_array($payload[0])) {
             logger('DEBUG', 'Error: not a valid db session payload!');
         } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) {
             logger('DEBUG', 'Error: session id has expired!');
         } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) {
             logger('DEBUG', 'Error: IP address in the session doesn\'t match this requests source IP!');
         } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) {
             logger('DEBUG', 'Error: User agent in the session doesn\'t match the browsers user agent string!');
         } else {
             // session is valid, retrieve the payload
             if (isset($payload[0]) and is_array($payload[0])) {
                 $this->keys = $payload[0];
             }
             if (isset($payload[1]) and is_array($payload[1])) {
                 $this->data = $payload[1];
             }
             if (isset($payload[2]) and is_array($payload[2])) {
                 $this->flash = $payload[2];
             }
         }
     }
     return parent::read();
 }
Esempio n. 20
0
 public static function log_error($message, $level = 'error')
 {
     if (!FBD_OUTPUT_ERROR_LOG_LEVEL) {
         return;
     }
     if (!in_array($level, array('error', 'warning', 'info', 'debug'))) {
         throw new InvalidArgumentException('Second parameter is invalid.');
     }
     switch (FBD_OUTPUT_ERROR_LOG_LEVEL) {
         case 'error':
             if (in_array($level, array('warning', 'info', 'debug'))) {
                 return;
             }
             break;
         case 'warning':
             if (in_array($level, array('info', 'debug'))) {
                 return;
             }
             break;
         case 'info':
             if ($level == 'debug') {
                 return;
             }
             break;
         case 'debug':
         default:
             break;
     }
     \Log::$level($message . ': ' . \Input::uri() . ' ' . \Input::ip() . ' "' . \Input::user_agent() . '"');
 }
Esempio n. 21
0
 public static function log_error($msg, $value)
 {
     Log::error($msg . ': ' . Input::uri() . ' ' . rawurlencode($value) . ' ' . Input::ip() . ' "' . Input::user_agent() . '"');
 }
Esempio n. 22
0
 /**
  * read the session
  *
  * @access public
  * @param
  *        	boolean, set to true if we want to force a new session to be created
  * @return Fuel\Core\Session_Driver
  */
 public function read($force = false)
 {
     // initialize the session
     $this->data = array();
     $this->keys = array();
     $this->flash = array();
     $this->record = null;
     // get the session cookie
     $cookie = $this->_get_cookie();
     // if a cookie was present, find the session record
     if ($cookie and !$force and isset($cookie[0])) {
         // read the session record
         $this->record = \DB::select()->where('session_id', '=', $cookie[0])->from($this->config['table'])->execute($this->config['database']);
         // record found?
         if ($this->record->count()) {
             $payload = $this->_unserialize($this->record->get('payload'));
         } else {
             // try to find the session on previous id
             $this->record = \DB::select()->where('previous_id', '=', $cookie[0])->from($this->config['table'])->execute($this->config['database']);
             // record found?
             if ($this->record->count()) {
                 $payload = $this->_unserialize($this->record->get('payload'));
             } else {
                 // cookie present, but session record missing. force creation of a new session
                 return $this->read(true);
             }
         }
         if (!isset($payload[0]) or !is_array($payload[0])) {
             // not a valid cookie payload
         } elseif ($payload[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) {
             // session has expired
         } elseif ($this->config['match_ip'] and $payload[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) {
             // IP address doesn't match
         } elseif ($this->config['match_ua'] and $payload[0]['user_agent'] !== \Input::user_agent()) {
             // user agent doesn't match
         } else {
             // session is valid, retrieve the payload
             if (isset($payload[0]) and is_array($payload[0])) {
                 $this->keys = $payload[0];
             }
             if (isset($payload[1]) and is_array($payload[1])) {
                 $this->data = $payload[1];
             }
             if (isset($payload[2]) and is_array($payload[2])) {
                 $this->flash = $payload[2];
             }
         }
     }
     return parent::read();
 }
Esempio n. 23
0
 /**
  * read a cookie
  *
  * @access	private
  * @return  void
  */
 protected function _get_cookie()
 {
     // was the cookie posted?
     $cookie = \Input::get_post($this->config['post_cookie_name'], false);
     // if not found, fetch the regular cookie
     if ($cookie === false) {
         $cookie = \Cookie::get($this->config['cookie_name'], false);
     }
     if ($cookie !== false) {
         // fetch the payload
         $cookie = $this->_unserialize(\Crypt::decode($cookie));
         // validate the cookie
         if (!isset($cookie[0])) {
             // not a valid cookie payload
         } elseif ($cookie[0]['updated'] + $this->config['expiration_time'] <= $this->time->get_timestamp()) {
             // session has expired
         } elseif ($this->config['match_ip'] && $cookie[0]['ip_hash'] !== md5(\Input::ip() . \Input::real_ip())) {
             // IP address doesn't match
         } elseif ($this->config['match_ua'] && $cookie[0]['user_agent'] !== \Input::user_agent()) {
             // user agent doesn't match
         } else {
             // session is valid, retrieve the session keys
             if (isset($cookie[0])) {
                 $this->keys = $cookie[0];
             }
             // and return the cookie payload
             array_shift($cookie);
             return $cookie;
         }
     }
     // no payload
     return false;
 }
Esempio n. 24
0
 protected static function log($msg, $method)
 {
     $uri = \Input::uri();
     $ip = \Input::ip();
     $agent = \Input::user_agent();
     $msg = $msg . ' [' . $uri . ' ' . $ip . ' "' . $agent . '"]';
     \Log::write('Auth', $msg, $method);
 }
Esempio n. 25
0
    public function action_send()
    {
        if (!\Security::check_token()) {
            \Log::error('CSRF: ' . \Input::uri() . ' ' . \Input::ip() . ' "' . \Input::user_agent() . '"');
            throw new HttpInvalidInputException('Invalid input data');
        }
        $val = $this->form()->validation();
        $val->add_callable('myvalidation');
        if ($val->run()) {
            $post = $val->validated();
            \Config::load('contact', true);
            $data = array();
            $data['email'] = $post['email'];
            $data['name'] = $post['name'];
            $data['to'] = \Config::get('contact.admin_email');
            $data['to_name'] = \Config::get('contact.admin_name');
            $data['subject'] = \Config::get('contact.mail_subject');
            $data['ip'] = \Input::ip();
            $data['ua'] = \Input::user_agent();
            $langs = implode(' ', $post['lang']);
            $data['body'] = <<<END
====================
名前: {$post['name']}
メールアドレス: {$post['email']}
IPアドレス: {$data['ip']}
ブラウザ: {$data['ua']}
====================
コメント: 
{$post['comment']}

性別: {$post['gender']}
問い合わせの種類: {$post['kind']}
好きな鳥: {$langs}
====================
END;
            try {
                $this->sendmail($data);
                $this->save($data);
                $this->template->title = 'コンタクトフォーム: 送信完了';
                $this->template->content = View::forge('contact/send');
            } catch (EmailValidationFailedException $e) {
                $this->template->title = 'コンタクトフォーム: 送信エラー';
                $this->template->content = View::forge('contact/error');
                \Log::error(__METHOD__ . ' email validation error: ' . $e->getMessage());
            } catch (EmailSendingFailedException $e) {
                $this->template->title = 'コンタクトフォーム: 送信エラー';
                $this->template->content = View::forge('contact/error');
                \Log::error(__METHOD__ . ' email sending error: ' . $e->getMessage());
            } catch (EmailSavingFailedException $e) {
                $this->template->title = 'コンタクトフォーム: 送信エラー';
                $this->template->content = View::forge('contact/error');
                \Log::error(__METHOD__ . ' email saving error: ' . $e->getMessage());
            }
        } else {
            $this->template->title = 'コンタクトフォーム: エラー';
            $this->template->content = View::forge('contact/index');
            $this->template->content->set_safe('html_error', $val->show_errors());
        }
    }