diff -ur -b --new-file guestbook/application/controllers/ListController.php guestbook2/application/controllers/ListController.php
--- guestbook/application/controllers/ListController.php	2009-04-15 05:40:01.000000000 +0900
+++ guestbook2/application/controllers/ListController.php	2009-04-25 04:24:44.000000000 +0900
@@ -12,6 +12,10 @@
 			'password' 	=> 'postgresql',
 			'dbname'	=> 'guestbook'
 		));
+		$this->view->setEncoding('UTF-8');
+		$this->view->setEscape('htmlentities');
+		ini_set('default_charset','UTF-8');
+		mb_internal_encoding('UTF-8');
     }
 
 
diff -ur -b --new-file guestbook/application/controllers/PostController.php guestbook2/application/controllers/PostController.php
--- guestbook/application/controllers/PostController.php	2009-04-15 06:05:24.000000000 +0900
+++ guestbook2/application/controllers/PostController.php	2009-04-25 04:24:54.000000000 +0900
@@ -13,6 +13,10 @@
 			'dbname'	=> 'guestbook'
 		));
 		date_default_timezone_set('Asia/Tokyo');
+	   	$this->view->setEncoding('UTF-8');
+		$this->view->setEscape('htmlentities');
+	    ini_set('default_charset','UTF-8');
+	    mb_internal_encoding('UTF-8');
     }
 
 
diff -ur -b --new-file guestbook/application/views/scripts/list/list.phtml guestbook2/application/views/scripts/list/list.phtml
--- guestbook/application/views/scripts/list/list.phtml	2009-04-15 05:38:04.000000000 +0900
+++ guestbook2/application/views/scripts/list/list.phtml	2009-04-18 05:42:36.000000000 +0900
@@ -10,9 +10,9 @@
 <table>
      <?php foreach ($this->rows as $row): ?>
      <tr><td>
-    日時: <?php echo htmlentities($row['date_created']) ?><br />
-     件名：<?php echo htmlentities($row['title']) ?> <br />
-     メッセージ:　<?php echo htmlentities($row['content']) ?><br />
+    日時: <?php echo $this->escape($row['date_created']) ?><br />
+     件名：<?php echo $this->escape($row['title']) ?> <br />
+     メッセージ:　<?php echo $this->escape($row['content']) ?><br />
      </td>
      </tr>
      <?php endforeach; ?>
diff -ur -b --new-file guestbook/application/views/scripts/post/post.phtml guestbook2/application/views/scripts/post/post.phtml
--- guestbook/application/views/scripts/post/post.phtml	2009-04-15 06:07:05.000000000 +0900
+++ guestbook2/application/views/scripts/post/post.phtml	2009-04-25 04:20:14.000000000 +0900
@@ -5,10 +5,10 @@
 <body>
 <div><p><a href="<?php echo $this->url(array('controller'=>'list')) ?>">一覧に戻る</a></p></div>
 <div>
-件名: <?php echo htmlentities($_POST['title']) ?><br />
+件名: <?php echo $this->escape($_POST['title']) ?><br />
 </div>
 <div>
-メッセージ:<?php echo htmlentities($_POST['content']) ?><br />
+メッセージ:<?php echo $this->escape($_POST['content']) ?><br />
 </div>
 </body>
 </html>
diff -ur -b --new-file guestbook/guestbook.sql guestbook2/guestbook.sql
--- guestbook/guestbook.sql	2009-04-15 01:28:00.000000000 +0900
+++ guestbook2/guestbook.sql	1970-01-01 09:00:00.000000000 +0900
@@ -1,2 +0,0 @@
-CREATE TABLE guestbook (id SERIAL PRIMARY KEY, title TEXT, content TEXT, date_created TIMESTAMP);
-
diff -ur -b --new-file guestbook/public/guestbook/guestbook.sql guestbook2/public/guestbook/guestbook.sql
--- guestbook/public/guestbook/guestbook.sql	1970-01-01 09:00:00.000000000 +0900
+++ guestbook2/public/guestbook/guestbook.sql	2009-04-15 01:28:00.000000000 +0900
@@ -0,0 +1,2 @@
+CREATE TABLE guestbook (id SERIAL PRIMARY KEY, title TEXT, content TEXT, date_created TIMESTAMP);
+
diff -ur -b --new-file guestbook/public/guestbook/index.php guestbook2/public/guestbook/index.php
--- guestbook/public/guestbook/index.php	2009-04-19 16:51:52.000000000 +0900
+++ guestbook2/public/guestbook/index.php	2009-04-22 04:48:05.000000000 +0900
@@ -1,2 +1,3 @@
 <?php
-include 'list/index.php';
+header('Location: http://'.rawurlencode($_SERVER['SERVER_NAME']).'/guestbook/list/');
+
diff -ur -b --new-file guestbook/public/guestbook/init.php guestbook2/public/guestbook/init.php
--- guestbook/public/guestbook/init.php	1970-01-01 09:00:00.000000000 +0900
+++ guestbook2/public/guestbook/init.php	2009-04-25 03:09:52.000000000 +0900
@@ -0,0 +1,12 @@
+<?php
+if (basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__)) {
+	trigger_error(__FILE__.' is called directly by '.$_SERVER['REMOTE_ADDR']);
+	die('Cannot call directly');
+}
+// 文字エンコーディングを設定する
+ini_set('default_charset', 'UTF-8');
+mb_internal_encoding('UTF-8');
+
+// ゲストブックデータベースを開く
+$db = new PDO('pgsql:host=localhost dbname=guestbook user=zfguestbook password=zfguestbook');
+
diff -ur -b --new-file guestbook/public/guestbook/list/index.php guestbook2/public/guestbook/list/index.php
--- guestbook/public/guestbook/list/index.php	2009-04-15 04:49:16.000000000 +0900
+++ guestbook2/public/guestbook/list/index.php	2009-04-18 03:41:23.000000000 +0900
@@ -1,13 +1,16 @@
 <?php
-// ゲストブックデータベースを開く
-$db = new PDO('pgsql:host=localhost dbname=guestbook user=postgres password=postgresql');
-// 全てのエントリを取得
-$stmt = $db->prepare('SELECT * FROM guestbook ORDER BY id DESC');
-$stmt->execute();
-$rows = $stmt->fetchAll();
-// データベースオブジェクトを削除
-$db = null;
+require '../init.php';
 
+try {
+	// 全てのエントリを取得
+	$stmt = $db->prepare('SELECT * FROM guestbook ORDER BY id DESC');
+	$stmt->execute();
+	$rows = $stmt->fetchAll();
+} catch (PDOException $e) {
+	// データベースにアクセスできない
+	trigger_error('DBにアクセスできません');
+	exit;
+}
 ?>
 <html>
 <head>
@@ -21,9 +24,9 @@
 <table>
 	 <?php foreach ($rows as $row): ?>
 	 <tr><td>
-	日時: <?php echo htmlentities($row['date_created']) ?><br />
-	 件名：<?php echo htmlentities($row['title']) ?> <br />
- 	 メッセージ:　<?php echo htmlentities($row['content']) ?><br />
+	日時: <?php echo htmlentities($row['date_created'], ENT_QUOTES, 'UTF-8') ?><br />
+	 件名：<?php echo htmlentities($row['title'],ENT_QUOTES, 'UTF-8') ?> <br />
+ 	 メッセージ:　<?php echo htmlentities($row['content'], ENT_QUOTES, 'UTF-8') ?><br />
 	 </td>
 	 </tr>
 	 <?php endforeach; ?>
diff -ur -b --new-file guestbook/public/guestbook/post/index.php guestbook2/public/guestbook/post/index.php
--- guestbook/public/guestbook/post/index.php	2009-04-15 05:52:40.000000000 +0900
+++ guestbook2/public/guestbook/post/index.php	2009-04-18 03:41:16.000000000 +0900
@@ -1,9 +1,8 @@
 <?php
+require '../init.php';
+
 try 
 {
-	// ゲストブックデータベースを開く
-	$db = new PDO('pgsql:host=localhost dbname=guestbook user=postgres password=postgresql');
-	
 	empty($_POST) ? define('POST',false) : define('POST', true);
 	
 	// フォームが送信されている
@@ -13,7 +12,8 @@
 	}
 } catch (PDOException $e) {
 	// データベースにアクセスできない
-	die('DBサーバへアクセス可能か確認してください');
+	trigger_errror('DBへアクセスできません');
+	exit;
 }
 
 
@@ -44,10 +44,10 @@
 <body>
 <div><p><a href="../list/">一覧に戻る</a></p></div>
 <div>
-件名: <?php echo htmlentities($_POST['title']) ?><br />
+件名: <?php echo htmlentities($_POST['title'], ENT_QUOTES, 'UTF-8') ?><br />
 </div>
 <div>
-メッセージ:<?php echo htmlentities($_POST['content']) ?><br />
+メッセージ:<?php echo htmlentities($_POST['content'], ENT_QUOTES, 'UTF-8') ?><br />
 </div>
 </body>
 </html>
