public static function start($dbname, $sql) { if (static::$profiler) { static::$query = array('sql' => \Security::htmlentities($sql), 'time' => static::$profiler->getMicroTime()); return true; } }
public function action_send() { //CSRF対策 if (!Security::check_token()) { throw new HttpInvalidInputException('ページの遷移が正しくありません'); } $val = $this->forge_validation(); if (!$val->run()) { $this->template->title = 'コンタクトフォーム:エラー'; $this->template->content = View::forge('form/index'); $this->template->content->set_safe('html_error', $val->show_errors()); $this->template->footer = View::forge('form/footer'); return; } $post = $val->validated(); $data = $this->build_mail($post); //メールの送信 try { //$this->sendmail($data); Package::load('email'); $email = Email::forge(); $email->from($data['from'], $data['from_name']); $email->to($data['to'], $data['to_name']); $email->subject($data['subject']); $email->body($data['body']); $email->send(); $this->template->title = 'コンタクトフォーム:送信完了'; $this->template->content = View::forge('form/send'); $this->template->footer = View::forge('form/footer'); return; } catch (EmailValidationFailedException $e) { Log::error('メール検証エラー:' . $e->getmesseage(), __METHOD__); $html_error = '<p>メールアドレスに誤りがあります</p>'; } catch (EmailSendingFailedException $e) { Log::error('メール送信エラー:' . $e->getmesseage(), __METHOD__); $html_error = '<p>メールを送信できませんでした</p>'; } $this->template->title = 'コンタクトフォーム:送信エラー'; $this->template->content = View::forge('form/index'); $this->template->content->set_safe('html_error', $html_error); $this->template->footer = View::forge('form/footer'); }
public function action_create() { if (Input::method() == 'POST') { // CSRF対策用トークンをチェック if (Security::check_token()) { // リクエストパラメータ(POST)に対してバリデーションを実施 $val = Model_Tuser::validate('create'); if ($val->run()) { // 入力値のサニタイズ(HTMLタグ、PHPタグ、およびHTMLエンティティを削除) $filters = array('strip_tags', 'htmlentities'); $name = Security::clean(Input::post('name'), $filters); $email = Security::clean(Input::post('email'), $filters); // ハッシュ化パスワードの生成 $salt = Util_Hash::getSalt(); $hashedPassword = Util_Hash::getHashedPassword(Input::post('password'), $salt); // リクエストパラメータからモデルのインスタンスを生成 $tuser = Model_Tuser::forge(array('name' => $name, 'email' => $email, 'hashed_password' => $hashedPassword, 'salt' => $salt, 're' => false)); // 新規ユーザーを登録 if ($tuser and $tuser->save()) { Session::set_flash('success', e('Added tuser #' . $tuser->id . '.')); Response::redirect('admin/tusers'); } else { Session::set_flash('error', e('Could not save tuser.')); } } else { Session::set_flash('error', $val->error()); } } } // CSRF対策用ワンタイムトークンを発行 $data['token_key'] = Config::get('security.csrf_token_key'); $data['token'] = Security::fetch_token(); // その他パラメータ $this->template->title = "Tusers"; $this->template->content = View::forge('admin/tusers/create', $data); }